Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Is there something wrong with application:getDeviceHeight() — Gideros Forum

Is there something wrong with application:getDeviceHeight()

Tom2012Tom2012 Guru
edited October 2015 in General questions
Hi,

I'm having problems using application:getDeviceHeight() and width...

On iphone 6 it gives me iphone 5 resolution.

1136 x 640

EDIT: If I check on screenresolution.org, it also states my resolution as

568 x 320 (same as above, only .5)

Why on earth is an iPhone 6 at the 'wrong resolution'? This is weird!

Comments

  • For some reason here it displays two resolutions for iphone 6, one of them is like iphone 5

    http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions
  • I think it's to do with up/down sampling based on pixel density. It's confusing. Someone should make a list of real, actual pixels only. :)

    What are you trying to do?
    My Gideros games: www.totebo.com
  • Tom2012Tom2012 Guru
    edited October 2015
    Hmm thats so odd!

    @ar2rawseen - Thanks for that url, although I've no idea why there's two resolutions. There's only one version of the iphone 6 (not counting the plus version). Anyway, going by that chart, the resolution being reported in Gideros is correct. The iphone 6 is upsampling it.

    @Totebo - I have a system in my game that checks if a sprite is outside of the screen. If it is, it sets the sprite to setVisible(false). And vice versa. It makes for a hefty performance increase. It does rely on being able to get the screen point size / x1 size / resolution accurately though.

    Thanks!
  • @Tom2012, I actually coded a system for this to be used with a Box2D world the other day. I have a "Camera" that locks onto the player and a method to get the boundaries based on the actual screen dimensions. Your requirements may be different, but this is the code in case it could be useful to you:
    function Camera:getBoundaries()
     
    	local x1 = self.sprite_player:getX() - (application:getLogicalWidth()/2)/self.sprite_gameworld:getScale() 
    	local y1 = self.sprite_player:getY() - (application:getLogicalHeight()/2)/self.sprite_gameworld:getScale() 
    	local x2 = self.sprite_player:getX() + (application:getLogicalWidth()/2)/self.sprite_gameworld:getScale() 
    	local y2 = self.sprite_player:getY() + (application:getLogicalHeight()/2)/self.sprite_gameworld:getScale() 
     
    	return x1, y1, x2, y2
     
    end
    I tested it on the XCode emulators, and it seems to work fine on iPhone 6.

    Niclas


    My Gideros games: www.totebo.com
  • @Totebo

    Awesome, thanks. Looks very efficient. I'll look into how it works.

    I've tracked down my problem and it's even more weird...

    On iphone 4, the game works fine.

    On iphone 6 and 6 plus there's a problem...
    function SpritesOffScreen:setup()
     
    	local t = Timer.new(450,math.huge)
    	t:addEventListener(Event.TIMER, self.cullOffScreenSprites, self)
    	t:start()
    	self.t = t
     
    end
     
     
    function SpritesOffScreen:cullOffScreenSprites()...
    The problem is the timer doesnt run on iphone 6 (device). I'll look into it and figure out what's up.
  • Hmm the problem is math.huge

    If I use math.huge on iphone 6 / 6 plus it does not work.

    If I use an int instead, like 99999, then there's no problems!
  • That is strange.

    I tend to have a game loop based on ENTER_FRAME that other classes subscribe to, so I can pause the game easily, and turn classes updating on or off to see how much CPU they use. So I've never bumped into this issue before.

    My Gideros games: www.totebo.com
Sign In or Register to comment.