10 years ago by DanielGray
I'm pretty sure I'm doing something slightly wrong, but when my character loads, the animation sheets don't seem to be preloading.
I set up the animation sheets then the separate animations in initialize, later on...
Later on, my logic dictates that idle is played inherently, and may delay loading as well but it is hard to tell.
The issue I am experiencing is, when the second animation sheet is loaded, it has a slight 0.1ish second delay before the anim plays and the character moves. The entire game freezes for a fraction of a second (because it is loading the animation sheet into RAM when the sheet is used I am guessing. After this happens, the game is extremely smooth and it does not happen again.
I am prototyping a game at the moment so that is all the functionable code for this character.
I set up the animation sheets then the separate animations in initialize, later on...
.defines(function() { EntityScarlette = ig.Entity.extend({ ScarletteIdle: new ig.AnimationSheet ( 'media/Scarlette/IdleScarlette.png', 420, 760 ), // ScarletteMove: new ig.AnimationSheet ( 'media/Scarlette/MovingScarlette.png', 420, 760 ), size: {x: 340, y : 640}, offset: {x: 30, y: 60 }, health: 10, maxVel: {x: 600, y: 2000}, friction: {x: 2000, y: 0}, flip: false, actionOne: false, accelGround: 440, init: function( x, y, settings){ this.parent( x, y, settings); this.idleAnim = new ig.Animation( this.ScarletteIdle, 0.1, [0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2,2,2,2,2,2,2,2,2,1]); this.movAnim = new ig.Animation( this.ScarletteMove, 0.04, [0,0,1,1,2,3,3,4,4,5,5,6,6,7,8,8,9,9]); },
Later on, my logic dictates that idle is played inherently, and may delay loading as well but it is hard to tell.
if( (ig.input.state('left') || ig.input.state('right')) && this.standing && !(this.actionOne) ){ this.currentAnim = this.movAnim; } else { this.currentAnim = this.idleAnim; }
The issue I am experiencing is, when the second animation sheet is loaded, it has a slight 0.1ish second delay before the anim plays and the character moves. The entire game freezes for a fraction of a second (because it is loading the animation sheet into RAM when the sheet is used I am guessing. After this happens, the game is extremely smooth and it does not happen again.
I am prototyping a game at the moment so that is all the functionable code for this character.