physics reversed when orientation is flipped

i set my game up in landscapeRight, and everything works fine, when i slide my finger to the left the object follows my finger, but when i flip my device to landscapeLeft, when i slide my finger to the left my object goes right. anyone have any ideas? [import]uid: 14967 topic_id: 11886 reply_id: 311886[/import]

@MatthewPerry,
did you try to set the gravity based on the orientation? That might help to keep the gravity right. After all the phone is doing what it is supposed to do in reality, but the finger movements are what you have coded.

Hope that made sense to you… Use the orientation event to set the game orientation and axis, etc

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 11886 reply_id: 43358[/import]

it makes sense and I get what you are saying. the gravity seems to be working ok, i just dont know how i would fix the object moving in the opposite directions, here is the code i am using for the touch event

[code]
local function onTouch( event )
local t = event.target

local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( t )
t.isFocus = true

t.x0 = event.x - t.x

elseif t.isFocus then
if “moved” == phase then
t.x = event.x - t.x0
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
t.isFocus = false
end
end

return true
end

fish:addEventListener ( “touch”, onTouch )
[/code] [import]uid: 14967 topic_id: 11886 reply_id: 43415[/import]

@Matthew,
the fun part of programming is that sometimes the solutions are the easiest and the most obvious ones, but they do cause a lot of grief till they are found.

one simple thing that you can do is have a axis scale, which is +1 for the right side and -1 for the other. so all your co-ordinates become

t.x = (event.x - t.x) * axisScale

and change the axisScale based on the orientation as you wish.

Hope that helps,

cheers,

?:slight_smile: [import]uid: 3826 topic_id: 11886 reply_id: 43419[/import]

ok i get that too, i dont know how to write the code to change the axisScale based on the orientation. if that makes sense [import]uid: 14967 topic_id: 11886 reply_id: 43420[/import]

Still cant get the direction right when the orientation is flipped :-/ [import]uid: 14967 topic_id: 11886 reply_id: 44509[/import]