Touch/Drag player paddle
Hi,
I'm trying to use a desktop AS3 pong-type game for a mobile deployment. This requires changing the player paddle's movement so that instead of following the mouse up or down on Y, it would allow for touch and be dragged up or down on Y by this touch gesture.
I haven't used touch gestures but have been reading at: http://help.adobe.com/en_US/as3/dev/WS1ca064e08d7aa93023c59dfc1257b16a3d6-7ffc.html
Need some help with scripting this. So far, have adapted the script found in the doc's first example, but cannot get it to work in the AIR/Android simulator/debugger in Flash CS6. I must be doing something wrong. No error messages, but it also doesn't drag the paddle in the debugger/simulator.
Here's the script so far. Any suggestions/help appreciated. Maybe, this needs a different scripting approach all-together?
playerPaddle.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
playerPaddle.addEventListener(TouchEvent.TOUCH_END, onTouchEnd);
function onTouchBegin(e:TouchEvent) {
e.target.startTouchDrag(e.touchPointID, false, playerPaddle.y);
trace("touch begin");
}
function onTouchEnd(e:TouchEvent) {
e.target.stopTouchDrag(e.touchPointID);
trace("touch end");
}
The original mouse drag script for the paddle was simple: playerPaddle.y = mouseY;