Heppell08 Posted January 15, 2014 Share Posted January 15, 2014 I've been messing around with Phaser and animating my sprite to do as i like. I have a jump/walk.jump left and jump right animation so far and im quite happy with it. Only issue i'm on to is animating the descent. I've animated alot in AS3 but ofcourse this isn't AS3 and i'm still relatively new to all this stuff. Anyway the code for my animating goes like this:if(player.body.velocity.x > 0) { player.animations.play('rightwalk'); } else if(player.body.velocity.x <0) { player.animations.play('leftwalk'); } if(player.body.velocity.x > 0 && player.body.velocity.y > 0) { player.animations.play('jumpright'); } else if(player.body.velocity.x < 0 && player.body.velocity.y > 0) { player.animations.play('jumpleft'); } else { if(facing === 'left') { player.frame = 0; } else if(facing === 'right') { player.frame = 1; } }I noticed some animations dont have the velocity.y >0 but i like to seperate my animations from the actual control mechanics of my game. But all im looking for is a descent animation so that the frame down as well as up for my jumping.Thanks //EDITSo i changed he code above and it seems to have resolved it. I moved it around so it now works looking like this:if(player.body.velocity.x > 0) { player.animations.play('rightwalk'); } else if(player.body.velocity.x <0) { player.animations.play('leftwalk'); } else { if(facing === 'left') { player.frame = 0; } else if(facing === 'right') { player.frame = 1; } } if(player.body.velocity.y > 0 && player.body.velocity.x > 0 ) { player.animations.play('jumpright'); } else if(player.body.velocity.y > 0 && player.body.velocity.x < 0) { player.animations.play('jumpleft'); }Moved the jump animations to below the elseSeems to work nicely now. Link to comment Share on other sites More sharing options...
Recommended Posts