Jelajahi Sumber

saving view in the model

Dima Mironov 10 tahun lalu
induk
melakukan
72765d2c54
3 mengubah file dengan 7 tambahan dan 0 penghapusan
  1. 5 0
      js/controller.js
  2. 1 0
      js/views/particle.js
  3. 1 0
      js/views/physicist.js

+ 5 - 0
js/controller.js

@@ -148,6 +148,11 @@ Controller.prototype.remove_collectible = function(collectible){
 	if (i > -1) {
 	    this.collectibles.splice(i, 1);
 	}
+	i = -1;
+	i = this.views.indexOf(collectible.view);
+	if (i > -1) {
+	    this.views.splice(i, 1);
+	}
 
 }
 

+ 1 - 0
js/views/particle.js

@@ -1,6 +1,7 @@
 (function(window) {
     function ParticleView(modelObject){
         this.model = modelObject;
+		this.model.view = this;
 		var dp = this.model.draw_properties;
 		var cs = window.cell_size;
         this.graphics

+ 1 - 0
js/views/physicist.js

@@ -2,6 +2,7 @@
     function PhysicistView(modelObject){
         this.graphics.beginFill("red").drawCircle(0, 0, window.cell_size * 0.9 / 2);
         this.model = modelObject;
+		this.model.view = this;
     }
 
     PhysicistView.prototype = new createjs.Shape();