Trouble getting the screen size of a 4 in iPhone

Monkey Targets Forums/iOS/Trouble getting the screen size of a 4 in iPhone

RobB(Posted 2014) [#1]
A small game app uses eng.GetCanvasHeight() to determine the screen size of the device. It seems to work properly for all the iPad/iPhone hardware types except the 4 in. iPhone, which it reports having a width of 640 instead of 1136. This is in the iOs Simulator, we don't have access to that size of device.

Any help is appreciated. (EDIT: also cross-posted on the fantom forums)

Here's the relevant bit of code, in case it is simply some typo:


'Create an instance of the fantomEngine and store it into the field 'eng'

'Create an instance of the fantomEngine and store it into the field 'eng'
eng = New engine
scrnW = eng.GetCanvasWidth()
scrnH = eng.GetCanvasHeight()
If scrnW = 576 And scrnH = 768 'html test mode
scale = 0.75; keyTilt = 1; deviceName = "html test mode"; imFolder = "L/"; sndFolder = "OGG/"; sndType = ".ogg"
EndIf
If scrnW = 320 And scrnH = 480 'old iPhone
scale = 1.0; keyTilt = 0; deviceName = "old iPhone"; imFolder = "M/"; sndFolder = "ACC/"; sndType = ".mp4a"
EndIf
If scrnW = 640 And scrnH = 960 'short retina iPhone, iPod Touch
scale = 2.0; keyTilt = 0; deviceName = "short retina iPhone or iPod Touch"; imFolder = "M/"; sndFolder = "ACC/"; sndType = ".mp4a"
EndIf
If scrnW = 1136 And scrnH = 640 'tall retina iPhone
scale = 2.0; keyTilt = 0; deviceName = "tall retina iPhone"; imFolder = "M/"; sndFolder = "ACC/"; sndType = ".mp4a"
EndIf
If scrnW = 768 And scrnH = 1024 'iPad 1, iPad 2, iPad Mini
scale = 1.0; keyTilt = 0; deviceName = "iPad 1, iPad 2, or iPad Mini"; imFolder = "L/"; sndFolder = "ACC/"; sndType = ".mp4a"
EndIf
If scrnW = 1536 And scrnH = 2048 'iPad 3 retina
scale = 2.0; keyTilt = 0; deviceName = "iPad 3 retina"; imFolder = "H/"; sndFolder = "ACC/"; sndType = ".mp4a"
EndIf


Qube(Posted 2014) [#2]
In the code above you are testing for device sizes in portrait mode yet for the iPhone 5 you have the resolutions switched to landscape. scrnW = 1136 And scrnH = 640 which should be scrnW = 640 And scrnH = 1136 (iPhone 5 in portrait mode)


RobB(Posted 2014) [#3]
Qube:
Yeah, sorry about. I tried switching W and H previously, and i guess it was still switched when i copied the code snippet. But either way it makes no difference, the app always thinks the simulated 4in iPhone is a 640 x 960 iPhone.


Sledge(Posted 2014) [#4]
Looks like you have to supply a retina launch image.

EDIT: Just tried this and can confirm that it works. Once you have 640x1136 launch image your app gets the full screen to play with.


MikeHart(Posted 2014) [#5]
...

Damn, have to remind myself to click on the topic title now first to see if others have replied too. :-/
(One thing I don't like about the new forum functionality regarding searches.)