Page 1 of 1

orientationChanged image angle

Posted: Fri Aug 10, 2012 2:37 pm
by goncalo
Hello, i have a problem with the orientation of iPhone.

I want that some images change the angle when a rotate the iphone, but with this code i don’t have the best result every time.
Some times the images change to the orientation of the iPhone, but some times they don’t rotate at all.

i send a file with the example, because i want the background image to stay on the same spot, and only the images of the buttons to change angle.

Does some else had this problem?

Code: Select all

on orientationChanged
   put mobileDeviceOrientation () into theOrientation
   if theOrientation = "portrait" then
      set the angle of image "butao_home_low.png" of card "game_stuff" to 90
   else if theOrientation = "portrait upside down" then
      set the angle of image "butao_home_low.png" of card "game_stuff" to 270
   else if theOrientation = "landscape left" then
      set the angle of image "butao_home_low.png" of card "game_stuff" to 180
   else if theOrientation = "landscape right" then
      set the angle of image "butao_home_low.png" of card "game_stuff" to 0
   end if
end orientationChanged
Thanks in advance.

Re: orientationChanged image angle

Posted: Sat Aug 11, 2012 2:38 am
by Mark
Hi,

Can you check whether the orientationChanged message isn't triggered or the images don't rotate properly? If the message isn't triggered, you could try using a recursive handler, which checks the mobiledeviceOrientation function.

Code: Select all

on openCard
  send "check" to me in 0 secs
  pass openCard
end opencard

local lPrevOrientation
on check
   put mobileDeviceOrientation () into theOrientation
   if lPrevOrientation <> theOrientation and there is an image "butao_home_low.png" of this cd then
     // orientation changed
     if theOrientation = "portrait" then
        set the angle of image "butao_home_low.png" of card "game_stuff" to 90
     else if theOrientation = "portrait upside down" then
        set the angle of image "butao_home_low.png" of card "game_stuff" to 270
     else if theOrientation = "landscape left" then
        set the angle of image "butao_home_low.png" of card "game_stuff" to 180
     else if theOrientation = "landscape right" then
        set the angle of image "butao_home_low.png" of card "game_stuff" to 0
     end if
     put theOrientation into lPrevOrientation
   end if
   if there is an image "butao_home_low.png" of this cd then send "check" to me in 333 millisecs
end check
Kind regards,

Mark