I was hoping if someone would care to help out a newb… my brain is having a hard time adapting to this process…
I would like the character to walk to a spot on the screen and stop. I found the following two excellent threads…
http://developer.coronalabs.com/forum/2012/05/16/moving-player-touch-event-position-constant-speed
http://corona.techority.com/2011/05/01/using-sprites-in-your-corona-iphone-application/
…which I partially got to work… however, once ‘guy’ gets to the spot, he doesn’t go back to his original standing pose.
[code]
local guy = sprite.newSprite (guyset)
guy.x = W * 0.5
guy.y = H * 0.5
guy:prepare(“stand”)
local function moveGuy(event)
distance = math.sqrt((event.x - guy.x) ^ 2 + (event.y - guy.y) ^ 2)
speed = 0.2
transition.to(guy,{time = (distance / speed),x = event.x , y = event.y })
guy:prepare(“walk”)
guy:play(“walk”)
if guy.x == event.x
and guy.y == event.y then
guy:prepare(“stand”)
end
end
Runtime:addEventListener(“tap”, moveGuy)
[/code] [import]uid: 158138 topic_id: 30601 reply_id: 330601[/import]