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?
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
physics reversed when orientation is flipped
@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 :-/
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
Link 2.6 is now available for iPhone, iPad, and Android... thanks, Corona!!
Is inMobi even working this weekend?!?
Does Corona don't work on SAMSUNG GT-S5830
When MovieClip complete do function?
Think Radical
Event sounds don't work on Android
All builds exit instantly when ran on device[RESOLVED]
Mute button
Build 591 causes app link to no longer work...