开发者

Corona swipe direction

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜