controls are reverse when switching orientation

Hi y’all,
I’m running into an issue that now users are reporting as problems.
I have my device to allow flipping/switching orientation (left/right - right/left) on landscape mode.

When my game is tilt to right, object moves right, and tilting left, moves left; however, when you flip/switch the device orientation, my controls are now reverse (tilt left moves right, and tilt right moves left).

I had read about how when you “flip” you need to take in account a negative number on your x/y or how x becomes y or the like; not sure how to overcome this obstacle.

Any help would be appreciated.

Thanks,
RD [import]uid: 7856 topic_id: 9337 reply_id: 309337[/import]

When you say “flipping/switching of orientation on landscape mode”, do you mean your app is a landscape app able to be played “both ways up” as required by Apple, or do you mean you’re handling the orientation change outside of the standard config settings to allow multiple orientations?

In the latter, you’d include the change to x and y in your flip function - but this may not be what you’re doing - more details would help :slight_smile: [import]uid: 52491 topic_id: 9337 reply_id: 34213[/import]

Hi Peach,
This is what I mean: “your app is a landscape app able to be played “both ways up” as required by Apple”.

This is my current code:

local function onAccelerate(event)  
 motiony = event.yGravity \* -45  
end  
Runtime:addEventListener("accelerometer", onAccelerate)  
local function fnMoveCar(event)  
 Car.x = Car.x + motiony  
end  
Runtime:addEventListener("enterFrame", fnMoveCar)  
  

Nothing seems to pop out as to why is causing that when I “flip” the orientation of the device (left to right and right to left) the object moves in opposite direction.

My main goal is for users to tilt to right and object moves to right and when tilt to left, object moves to left…Regardless of device landscape orientation mode.

I think what the code is doing makes sense on how is behaving, but some people are reporting this as a problem (mainly annoying).

If there’s a fix for this and/or workaround, I’ll like to provide to customers.

Thanks,
RD [import]uid: 7856 topic_id: 9337 reply_id: 34316[/import]

Hey again,

http://developer.anscamobile.com/reference/index/systemorientation

Check that link out.

I’ve never had an issue with things not moving correctly on rotation to a new orientation, however if I did I’d likely use the above API in a function to state if it was in whichever orientation is causing the problems, do -x rather than +x, or the like.

I hope that makes sense; if not let me know and I’ll try to reword it when I’m more full of caffeine ^-^;

Peach :slight_smile: [import]uid: 52491 topic_id: 9337 reply_id: 34361[/import]

Hi Peach,
If you have the code handy that’ll be awesome, if not, don’t worry about it, I’ll try to figure it out.

I guess I got spoiled a little bit and took for granted the ‘minor’ things like this being taken care of behind the scenes with ‘GS’ :wink:

Thanks,
RD [import]uid: 7856 topic_id: 9337 reply_id: 34474[/import]

I don’t have it handy but I’m sure you can figure it out, you’ve done MUCH more complex things previously :slight_smile: [import]uid: 52491 topic_id: 9337 reply_id: 34524[/import]

hadn’t been here in a while and just trying to pick this code again and found the post.

This is what I’m trying to do and still not working (my settings are default to landscaperight)

local function onAccelerate( event )  
 motiony = (event.yGravity \* -45)  
end  
  
local function moveBasket(event)  
  
 if system.orientation == "landscapeRight" then  
 basket.x = basket.x + motiony  
 else  
 basket.x = basket.x + -(motiony)  
 end  
  
end  

both functions are running based on eventlisteners.
if you start the game in landscapeleft, it seems like it works, but flipping again, it doesn’t seem to pick the correct motiony (+/-)

any feedback would be appreciated.

Thanks,
RD [import]uid: 7856 topic_id: 9337 reply_id: 46901[/import]