Hi,
Here’s a video of the situation. Basically, the player animates in different directions when she walks just fine – if I click one direction, let up, click another, let up, repeat.
However, if I hold down the D-pad and move over various directions, she just slides around - not actaully starting the animation that goes with the direction she is moving. I’ve tried a lot of things, but am stumped.
See video explanation: http://screencast.com/t/TwkAKIWGe
if event.phase == “began” then
player:toFront()
display.getCurrentStage():setFocus(event.target, event.id)
event.target.isFocus = true
end
if event.phase == “began” or event.phase == “moved” then
local xdirection = event.x - 75
local ydirection = event.y - 252
local angle = getangle(xdirection, ydirection)
if(angle >= -45 and angle <= 45) then
G.player_facingdirection = “north”
player:setSequence( “up” )
elseif(angle > 45 and angle <= 135) then
G.player_facingdirection = “east”
player:setSequence( “right” )
elseif(angle > 135 and angle <= 225) then
G.player_facingdirection = “south”
player:setSequence( “down” )
else
G.player_facingdirection = “west”
player:setSequence( “left” )
end
player:play()
player.linearDamping = 0
local yposneg = 0
if(ydirection < 0) then
yposneg = -1
else
yposneg = 1
end
local xposneg = 0
if(xdirection < 0) then
xposneg = -1
else
xposneg = 1
end
if(math.abs(xdirection) > math.abs(ydirection)) then
ydirection = math.abs(ydirection / xdirection) * yposneg
xdirection = 1 * xposneg
else --ydirection is greater than x.
xdirection = math.abs(xdirection / ydirection) * xposneg
ydirection = 1 * yposneg
end
moveobject(player, xdirection, ydirection, G.player_speed)
end
if event.phase == “ended” or event.phase == “cancelled” then
display.getCurrentStage():setFocus( event.target, nil )
event.target.isFocus = false
accy = 0
accx = 0
player:setLinearVelocity(0,0)
player.linearDamping = G.player_lineardampening
player:pause()
end