2015-04-01 68 views
0

任何人都可以帮助我。我为跳动画创建了一些精灵图像。但它不能像我想要的那样动画,它只显示第一帧(我将它设置为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) 

三江源非常 问候

回答

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 
+0

是啊,我忘了:) – 2015-05-02 06:04:36