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?

@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,

?:)

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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 )

@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,

?:)

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

Still cant get the direction right when the orientation is flipped :-/

views:1636 update:2011/9/28 21:38:26
corona forums © 2003-2011