Player doesn't animate until I let up - How to fix? See Video

Hi,

See video explanation: http://screencast.com/t/TwkAKIWGe

Here’s the code:

I’ve tried moving around player:pause() and a few other things, but doesn’t seems to fix the animation. Thanks for your help!

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

Here’s the code:

I’ve tried moving around player:pause() and a few other things, but doesn’t seems to fix the animation. Thanks for your help!

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