DeviceWidth / DeviceHeight reporting 0 on iOS

Monkey Targets Forums/iOS/DeviceWidth / DeviceHeight reporting 0 on iOS

frank(Posted 2013) [#1]
Using xcode 4.5 with iOS 5.1 or 6 Monkey69 reports width=height=0.

Debugging shows that this;

MonkeyAppDelegate *appDelegate=(MonkeyAppDelegate*)[[UIApplication sharedApplication] delegate];
width=appDelegate->view->backingWidth;
height=appDelegate->view->backingHeight;

always returns 0 while Monkey66 reported correct values. What am I doing wrong?


Steven(Posted 2013) [#2]
Same issue here. v69 on a iPad1. AFAIK it's a bug in v69.

I'm trying v66 to see if its solves the problem.


frank(Posted 2013) [#3]
In v66 it works for me; it uses this;

bool gxtkGraphics::Validate(){
width=app->appDelegate->view->backingWidth;
height=app->appDelegate->view->backingHeight;
return width>0 && height>0;
}

to get that info; it seems app->appDelegate != (MonkeyAppDelegate*)[[UIApplication sharedApplication] delegate]

?


Steven(Posted 2013) [#4]
I followed the startup of the app a bit in the debugger but since i'm far from an expert in the gory details of Objective-C and iOS i was lost quickly.

Anyway, i've made a bug report.

g.


frank(Posted 2013) [#5]
Where are you checking DeviceWidth / DeviceHeight in your code? Because it does seem to work once you are rendering, but not before which breaks, for instance, Diddy.


Steven(Posted 2013) [#6]
Nice!

I did set a virtual resolution in the OnCreate method of my app.

I tried to move the logic to the OnUpdate method and now it works.

Thanks for the tip!


frank(Posted 2013) [#7]
No problem. But I do think it's a bug still that it doesn't know it's resolution OnCreate of the App :) At least now it works, so no worries.


Grey Alien(Posted 2013) [#8]
I see Mark fixed this, but was this just broken in V69 because I've been reading those values fine in OnCreate in previous versions.


Steven(Posted 2013) [#9]
Did you test it on an iPad1 with iOS 5.1.1?


frank(Posted 2013) [#10]
It still seems to be broken (from v69 and up) on iPad1 with OS 5 (don't know the exact version at the moment). It was working before that because my app broke which is actually in the Appstore and tested on the same iPad1. After updating Monkey it stopped working.

Another interesting side effect seems to be that on the same iPad1 the screen remains black until I execute SetGraphics manually, like so

If Not inited And DeviceWidth > 0
SetGraphics DeviceWidth, DeviceHeight
inited = True
End

In the update method. Otherwise apparently it runs on resolution 0,0, which is rather small :)


nigelibrown(Posted 2013) [#11]
Using an iPhone4s and DeviceWidth() reports as 480 DeviceHeight() reports 320?

MonkeyPro69


Xaron(Posted 2013) [#12]
You might have to use a launch image to set the correct values. At least this is necessary for the newer iPhone5.