Hello Community, I have a problem with the movement of my char (Left-Right or Right-Left) , I’ll explain it this way:
- Touch Left (Without Releasing).
- Tocuh Right (While I pressing Left, so the char continues moving to left)*
- Touch Left Ended (Without Releasing Touch Right).
- Here’s the Problem: My char should move to right, but the char doesn’t move to right, it just stops.
I don’t know if I should use multitouch or something else, please, somebody help me.
– I tested activating multitouch, but the problem with multitouch is:
- Touch Left (Without Releasing).
- Tocuh Right (While I pressing Left, the char changes its movement to Right)*
- Touch Left Ended (Without Releasing Touch Right)
- Here’s the Problem: My char should move to right, but the char doesn’t move to right, it just stops.
*Did you see the difference?
Here’s the code:
[code]
–Movement Direction
function moveDirection (e)
if ( e.x > (wScreen * 0.5) and e.x < wScreen ) then
motionX = speedX
elseif ( e.x > 0 and e.x < (wScreen * 0.5) ) then
motionX = -speedX
end
end
–Listener
Runtime:addEventListener ( “touch”, moveDirection )
–Movement
function movement ()
square.x = square.x + motionX
end
–Listener
Runtime:addEventListener ( “enterFrame”, movement )
–Stop Movement
function moveStop (e)
if ( e.phase == “ended” ) then
motionX = 0
end
end
–Listener
Runtime:addEventListener ( “touch”, moveStop )
–Movement Wrap
function moveWrap ()
if ( square.x < 12 ) then
square.x = 12
elseif ( square.x > (wScreen - 12) ) then
square.x = wScreen - 12
end
end
–Listener
Runtime:addEventListener ( “enterFrame”, moveWrap ) [import]uid: 81091 topic_id: 18097 reply_id: 318097[/import]
[import]uid: 52491 topic_id: 18097 reply_id: 69529[/import]