This is from a plugin with a menu and it displays a sprite. walking facing down, left, up and right and repeats. it originally show a 3 x 4 sprite sheet. I have changed the sheet to a 8 x 4. It work but the preview frame order isn't 1 through 8 like I need it to be. It plays them in a weird order.
Any Ideas?
Sprite_DisplayCharacter.prototype = Object.create(Sprite_Base.prototype);
Sprite_DisplayCharacter.prototype.constructor = Sprite_DisplayCharacter;
Sprite_DisplayCharacter.prototype.initialize = function() {
Sprite_Base.prototype.initialize.call(this);
this._stepCounter = 1;
this._stepDirection = 1;
this._directionCounter = 0;
this._directions = [0, 1, 3, 2];
this._specificCounter = 0;
this.visible = false;
this.refresh();
};
Sprite_DisplayCharacter.prototype.update = function() {
Sprite_Base.prototype.update.call(this);
this._specificCounter++;
if(this._specificCounter % 10 === 0) {
this._stepCounter += this._stepDirection;
if(this._stepCounter === 7 || this._stepCounter === 1) this._stepDirection *= (-1);
this.refresh();
}
if(this._specificCounter % 120 === 0) {
this._directionCounter++;
if(this._directionCounter > 3) this._directionCounter = 0;
this.refresh();
}
};
Sprite_DisplayCharacter.prototype.refresh = function(reset) {
if(reset) {
this._stepCounter = 1;
this._stepDirection = 1;
this._directionCounter = 0;
this._specificCounter = 0;
}
this.setFrame(_.width * this._stepCounter, _.height * this._directions[this._directionCounter],
_.width, _.height);
if(!this.visible) this.visible = true;
};
Any Ideas?