Tried to fire up an error to switch to landscape, code below tries to capture aspect and switchover when turned. I think the print statement in this eventually caused the crash. Is this a flaw or is there a better way to do this ?
I’m sure I got this to work in the past.
function setup()
--
aspect = WIDTH/HEIGHT
end
function draw()
--
aspect = WIDTH/HEIGHT
while aspect < 1 do
— print(aspect)
if aspect > 1 then
break
end
end
print(aspect)
end
Edit : sorted this - just used an if else then loop but don’t know why the other loops don’t exit.
@Bri_G If the aspect is less than 1 you’ll enter the while loop, but you’ll never enter the greater than 1 for the break in there. Are you trying to have the user be in a certain mode, portrait of landscape.
If you want code to force the user to a certain mode, here’s what I use.
viewer.mode=FULLSCREEN
function setup()
fill(255)
end
function draw()
background(0)
if CurrentOrientation~=LANDSCAPE_LEFT then
text("Rotate device to landscape left",WIDTH/2,HEIGHT/2)
end
end
@dave1707 - thanks for the feedback, as I commented later in my post I managed to achieve it with just an if else end loop. I was just frustrated I couldn’t find a way to use the while … end or the repeat until loops.