some troubles again(
WalkToTapPos = function( event )
--Positions
local P1 = {}
local P2 = {}
P1.x, P1.y = math.ceil( char\_walk.x ), math.ceil( char\_walk.y )
P2.x, P2.y = math.ceil( event.x ), math.ceil( event.y )
--Compute s=Weg
local kat\_a = P2.x - P1.x
local kat\_b = P2.y - P1.y
local s = math.sqrt( kat\_a^2 + kat\_b^2 ) --Quadrieren, Addieren und Wurzel berechnen
--v=Geschwindigkeit (Pixel/Seconds)
local v = 50/1 --AJUST SPEED HERE!!
--t=Zeit (Weg/Geschw.)
local t = s/v
print( "You've tapped. Char will move from: x=" .. P1.x .. ", y=" .. P1.y .. " to: x=" .. P2.x .. ", y=" .. P2.y )
local char\_tween = transition.to( char\_walk, { time = t\*1000, x = P2.x, y = P2.y } )
end
Runtime:addEventListener( "tap", WalkToTapPos )
I “Tap” and the Transition.to() plays.
When I “Tap” again (but the transition is not ready yet) a new transition plays and then weirdly jumps back to the first one, and completes that. How to fix that?
It should actually work, because every movement is computed every time, when tap event happens. [import]uid: 73502 topic_id: 13383 reply_id: 313383[/import]
Thanks, works like a charm!