Bläddra i källkod

Added a delay to the animation of each new physicist.

John Lång 10 år sedan
förälder
incheckning
5279f3f49b
3 ändrade filer med 4 tillägg och 3 borttagningar
  1. 2 1
      js/models/physicist.js
  2. 1 1
      js/models/snake.js
  3. 1 1
      js/views/physicist.js

+ 2 - 1
js/models/physicist.js

@@ -1,9 +1,10 @@
-var Physicist = function(snake, position) {
+var Physicist = function(snake, position, delay) {
 	this.direction = 0;
 	this.position = position;
 	this.name = 'Fermi';
 	this.bonus = '';
 	this.snake = snake;
+	this.delay = delay;
 };
 
 Physicist.prototype.collect = function(collectible) {

+ 1 - 1
js/models/snake.js

@@ -1,7 +1,7 @@
 var Snake = function(n_physicisits){
 	this.physicists = [];
 	for (var i = 0; i < n_physicisits; i++){
-		this.physicists.push(new Physicist(this, {x: 0, y: 0}));
+		this.physicists.push(new Physicist(this, {x: 0, y: 0}, i % 8));
 	}
     this.physicists[0].direction = {x: 0, y: 0};
 	this.new_physicists = [];

+ 1 - 1
js/views/physicist.js

@@ -17,7 +17,7 @@
         this.scaleY = scale;
         this.spriteSheet = spriteSheet;
         this.gotoAndPlay("run");
-        this.currentAnimationFrame = Math.floor(Math.random() * 7);
+        this.currentAnimationFrame = modelObject.delay;
         this.model = modelObject;
 		this.model.view = this;
     }