I am dispatching events when user touches the screen and removes the touch. But, the event is dispatched only once, I want the Touches_End event to be dispatched continuously until user touches the screen, how can I do that?Please?
I tried updating it in Event.Enters_Frame function and added listener in Event.TOUCH_ENDS function, but it doesn't work.
function Play: whenEntersFrame()
speed = 20
x,y = mc1:getPosition()
repeat
y = y+ speed
mc1:setPosition(x, y)
until self.touchStarted ~= true
end
Comments
you can try to emulate it, but it is not recommended
basically if you want to do something while user touches the screen, you better do it inside the enter frame
and
1) And why are you using until loop? it means it will always be called at least once
2) why would you use loop at all? enter frame in itself is a loop, and is called on every frame,
simply this should be enough
if self.touchStarted then
mc1:setY(mc1:getY()+ speed)
end
The player just keeps going down and I want that when self.touchStarted is not true.
I did this:
if not self.touchStarted then
mc1:setY(mc1:getY()+ speed)
end
and player doesn't at all appears on the screen. Why that might be happening?
self.touchStarted = true when Touch begins and self.touchStarted = false when touch ends