Hello.
The value of the HEIGHT constant (really variable, I think) is 768 (iPad 2, set in PORTRAIT mode) at the start of the FIRST execution of a program. Look this code (Main tab):
print("First line:", HEIGHT)
function setup()
print("Inside setup:", HEIGHT)
end
The output is:
First line: 768
Inside setup: 1024
If you re-execute, the output is:
First line: 1024
Inside setup: 1024
Is this a bug?
Best regards,
Rodolfo.
iPad 3, works good, make sure you dont rotate device
This is known about, but I can’t find the relevant discussion right now. It’s to do with when Codea gets the information about the orientation, if I remember right. So you need to ensure that you don’t use HEIGHT
or WIDTH
until setup()
knows what the orientation will be.
Thanks. The strangest thing is that it only occurs with Codea just started; after any project is executed, HEIGHT (or WIDTH, I suppose) is correctly reported.
i’m guessing you don’t change the orientation of your iPad so once it is right for the first run, it stays right. Try turning your iPad between runs and see what happens.
You are right, Andrew. If I turn the iPad the first line show the old incorrect value.