1 decade ago by Joncom
EDIT As it turned out the thread name is missleading. Frames were not being skipped, but rather not selected when it was expected they would be.
-----------
When I run
To demonstrate the problem I ran the following:
The output:
Here is the entirety of my code:
Why are certain frames inaccessible?
-----------
When I run
currentAnim.gotoFrame(11)
, you would think currentAnim.frame
would then be set to 11. But it is not. Why?To demonstrate the problem I ran the following:
var frameCount = ig.game.player.currentAnim.sequence.length; for(var i=0; i<frameCount ; i++) { ig.game.player.currentAnim.gotoFrame(i); var frame = ig.game.player.currentAnim.frame; if(i !== frame) { console.log('Called gotoFrame(' + i + ') but frame is still ' + frame); } }
The output:
Called gotoFrame(11) but frame is still 10
Called gotoFrame(15) but frame is still 14
Called gotoFrame(22) but frame is still 21
Called gotoFrame(30) but frame is still 29
Here is the entirety of my code:
/* main.js */ ig.module('game.main') .requires('impact.game', 'game.entities.player') .defines(function(){ MyGame = ig.Game.extend({ init: function() { this.player = this.spawnEntity( EntityPlayer, ig.system.width/2, ig.system.height/2 ); } }); ig.main('#canvas', MyGame, 60, 480, 320, 2); });
/* player.js */ ig.module('game.entities.player') .requires('impact.entity') .defines(function(){ EntityPlayer = ig.Entity.extend({ size: {x: 60, y:60}, animSheet: new ig.AnimationSheet('media/player/aim-grenade.png', 60, 60), init: function( x, y, settings ) { this.parent( x, y, settings ); this.addAnim('aimGrenade', 0.03, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14, 15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]); } }); });
Why are certain frames inaccessible?