Add: prev and next animal icon image in typing practice
This commit is contained in:
+24
-16
@@ -4,6 +4,21 @@ function Animal(type, x, y) {
|
||||
this.sprite = null;
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
|
||||
this.sprite = game.add.sprite(this.posX, this.posY); //, "snail_run1"); // this.spriteFrameNames.run1);
|
||||
this.sprite.anchor.set(0.5);
|
||||
}
|
||||
|
||||
|
||||
Animal.prototype.setIconSprite = function(species) {
|
||||
this.setSpecies(species);
|
||||
|
||||
this.spriteFrameNames = this.loadSpriteNames();
|
||||
this.sprite.loadTexture(this.spriteFrameNames.run1);
|
||||
}
|
||||
|
||||
Animal.prototype.setSpecies = function(species) {
|
||||
this.species = species;
|
||||
}
|
||||
|
||||
Animal.prototype.loadSpriteNames = function() {
|
||||
@@ -17,15 +32,11 @@ Animal.prototype.loadSpriteNames = function() {
|
||||
return spriteNames;
|
||||
}
|
||||
|
||||
Animal.prototype.setSpecies = function(species) {
|
||||
this.species = species;
|
||||
|
||||
if(this.animalType === Animal.TYPE_ICON)
|
||||
return;
|
||||
|
||||
this.setupAnimation();
|
||||
Animal.prototype.setAlpha = function(value) {
|
||||
this.sprite.alpha = value;
|
||||
}
|
||||
|
||||
|
||||
Animal.prototype.tweenAnimation = function(animationType) {
|
||||
switch(animationType) {
|
||||
case Animal.ANIMATION_TYPE_CHANGE:
|
||||
@@ -41,7 +52,6 @@ Animal.prototype.tweenAnimation = function(animationType) {
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Animal.prototype.setupAnimation = function() {
|
||||
@@ -50,18 +60,14 @@ Animal.prototype.setupAnimation = function() {
|
||||
this.animationFrameID = 1;
|
||||
this.animationSpeedSec = 1000 / this.species.runningFPS;
|
||||
|
||||
if(this.sprite === null) {
|
||||
this.sprite = game.add.sprite(this.posX, this.posY, this.spriteFrameNames.run1);
|
||||
this.sprite.anchor.set(0.5);
|
||||
this.sprite.width = 150;
|
||||
this.sprite.height = 150;
|
||||
}
|
||||
|
||||
this.stopAnimation();
|
||||
this.animateionUpdate();
|
||||
}
|
||||
|
||||
Animal.prototype.startAnimation = function() {
|
||||
Animal.prototype.startAnimation = function(species) {
|
||||
this.setSpecies(species);
|
||||
this.setupAnimation();
|
||||
|
||||
if(this.timerEvent === null)
|
||||
this.timerEvent = game.time.events.loop(this.animationSpeedSec, this.animateionUpdate, this);
|
||||
}
|
||||
@@ -74,6 +80,8 @@ Animal.prototype.animateionUpdate = function() {
|
||||
} else {
|
||||
this.sprite.loadTexture(this.spriteFrameNames.run1);
|
||||
}
|
||||
this.sprite.width = 150;
|
||||
this.sprite.height = 150;
|
||||
}
|
||||
|
||||
Animal.prototype.stopAnimation = function() {
|
||||
|
||||
Reference in New Issue
Block a user