开发者

Corona swipe direction

开发者 https://www.devze.com 2023-03-22 14:35 出处:网络
I am working on a game using Corona sdk. I need to determine a swipe direction, so I can make a body object jump in that direction. I am using Ru开发者_如何学Gontime:addEventListener(\"touch\", moveCa

I am working on a game using Corona sdk. I need to determine a swipe direction, so I can make a body object jump in that direction. I am using Ru开发者_如何学Gontime:addEventListener("touch", moveCat) which calls a function moveCat which moves the body object. It is working, but the object moves in the wrong direction. When I swipe up and left, it jumps up and right. Inside the moveCat function I am using cat:applyLinearImpulse( 50, 150, event.x, event.y ) to move the object.

Any suggestions are appreciated.

Jerry


It would probably help if you posted specific code, but in general, for swipes, I store the starting (x1,y1) coordinates and compare them to the ending (x2,y2) coordinates. If x2>x1 then the user swiped from left to right.

0

精彩评论

暂无评论...
验证码 换一张
取 消