我无法为精灵制作动画,我做错了什么?

时间:2015-04-01 23:57:47

标签: animation corona

任何人都可以帮助我。我为跳跃动画创建了一些精灵图像。但它不能动画我想要的,它只显示第一帧(我设置为7跳帧)。这是我的电晕代码。

    function playerJump( event )
    if event.phase == "ended" then
        if doubleJump == false then 
            player:setLinearVelocity( 0, 0 )
            player:applyForce(0,-30, player.x, player.y)
            player:setSequence("jump")
            jumpChannel = audio.play(jumpSound)
        end

        if singleJump == false then singleJump = true 
        else doubleJump = true end
    end
    return true
end

然后在该函数下面,我生成精灵

        local options = 
    {
        width = 60, height = 100,
        numFrames = 33,
        sheetContentWidth = 1980,
        sheetContentHeight = 100
    }
    playerSheet = graphics.newImageSheet( "images/playerSprite.png", options)
    playerSprite = { 
        {name="run", frames = {1,3,5,7,9,11,13,15,17,19,21,23,25}, time = 700, loopCount = 0 },
        {name="jump", frames = {27,28,29,30,31,32,33}, time = 1000, loopCount = 1 },
    }

    --Add the jump listener
    Runtime:addEventListener("touch", playerJump)

非常感谢你 此致

1 个答案:

答案 0 :(得分:0)

function playerJump( event )
 if event.phase == "ended" then
    if doubleJump == false then 
        player:setLinearVelocity( 0, 0 )
        player:applyForce(0,-30, player.x, player.y)
        player:setSequence("jump")
        player:play() --- You have forgot to add this line.
        jumpChannel = audio.play(jumpSound)
    end

    if singleJump == false then singleJump = true 
    else doubleJump = true end
  end
  return true
end