From 29bc047ffecb3621396b52a3e8b1fa48155d62ca Mon Sep 17 00:00:00 2001 From: flashhawk Date: Wed, 20 Nov 2013 15:19:13 +0800 Subject: [PATCH] fix bugs --- build/spp.min.js | 2 +- src/particles/Particle.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/build/spp.min.js b/build/spp.min.js index 175f318..19e76df 100644 --- a/build/spp.min.js +++ b/build/spp.min.js @@ -15,7 +15,7 @@ this.x)},isPerpTo:function(a){return 0==this.dot(a)},angleBetween:function(a){a= SPP.Particle.prototype={constructor:SPP.Particle,init:function(a,b,c){0>=c&&(c=-Infinity);this.position=SPP.VectorPool.get();this.velocity=SPP.VectorPool.get();this.acceleration=SPP.VectorPool.get();this.damp=SPP.VectorPool.get();this.damp.reset(0.1,0.1);this.life=c||Infinity;this.position.reset(a,b)},getForce:function(a){return this._forcesMap[a]},addForce:function(a,b){this._forcesMap[a]=b},removeForce:function(a){this._forcesMap[a].target===this&&(this._forcesMap[a].life=0);delete this._forcesMap[a]}, removeAllForces:function(){for(var a in this._forcesMap)this.removeForce(a)},render:function(){this.update();this.onUpdate&&this.onUpdate.apply(this);if(null!=this.group){var a=this.group.getForceMap(),b;for(b in a)a[b].render(this)||delete a[b]}for(b in this._forcesMap)this._forcesMap[b].render(this)||this.removeForce(b);this.velocity.add(this.acceleration);this.acceleration.reset(0,0);this.velocity.x*=1-this.damp.x;this.velocity.y*=1-this.damp.y;this.position.add(this.velocity);this.zone&&this.zone.render(this); this.life-=SPP.frameTime;0<=this.life||(this.dispatchEvent(new SPP.Event("dead")),this.reset())},update:function(){},dealloc:function(){SPP.VectorPool.recycle(this.position);SPP.VectorPool.recycle(this.velocity);SPP.VectorPool.recycle(this.acceleration);SPP.VectorPool.recycle(this.damp);this.group=this.zone=this.onUpdate=this.extra=this._forcesMap=this.life=this.damp=this.acceleration=this.velocity=this.position=null},reset:function(){SPP.VectorPool.recycle(this.position);SPP.VectorPool.recycle(this.velocity); -SPP.VectorPool.recycle(this.acceleration);SPP.VectorPool.recycle(this.damp);this.acceleration=this.velocity=this.position=null;this.life=0;this.removeAllForces();this.removeAllEventListeners();for(var a in this.extra)delete this.extra[a];this.group=this.zone=this.onUpdate=null}};SPP.extend(SPP.Particle.prototype,SPP.EventDispatcher.prototype);SPP.Pool=function(){var a=[];this.get=function(b){for(var c in a)if(a[c].constructor===b)return a.splice(c,1)[0];return new b};this.recycle=function(b){a.push(b)};this.getObjects=function(){return a};this.dealloc=function(){for(var b=0,c=a.length;b=a[c].life&&(SPP.particlePool.recycle(a[c]),a.splice(c,1));for(c=b.length;0=b[c].life&&(SPP.forcePool.recycle(b[c]),b.splice(c,1))}};this.start= function(){d=Date.now();g=!0};this.stop=function(){g=!1};this.destroy=function(){this.stop();g=d=null;for(var e=0,f=a.length;ethis.boundary.right())a.position.x=a.position.xthis.boundary.bottom())a.position.y=a.position.y