var STAND = 0; var GUM = 1; var BRIDGE = 2; var LIFT = 3; var TRUCK = 4; var CIRCLE = 5; var BALLOON = 6; var WHEEL = 7; function Jelly(game,tex_name,x,y,map,obj_name,offx,offy,index) { this.game = game; this._sprite = this.game.add.image(x,y,tex_name); this._sprite.anchor.set(offx,offy); this._xp = x; this._yp = y; this._bodies =[]; this._pop ={tx:0,ty:0,tw:0,th:0,ta:0,td:0,tf:0,tb:0,tad:0,tld:0,se:false,fx:false,cb:0,mb:0,ot:0,jot:0,lm:false,jll:0,jul:0,mo:false,msp:0,mtq:0,sp:[],st:false,gr:0,bl:false,arc:0.0}; this._box; this._bump; this._vbump = {tx:0,ty:0,tw:0,th:0}; this._index = index; this._mask = this.game.add.graphics(0, 0); this._createJelly(map,obj_name); this.joint; this.time_trail =0; this._exSprite; this._link =[]; this.object_name = obj_name; this.renderJelly(); // this._index=index; }; Jelly.prototype.enablePrimatic = function(ground,low,up,ax,ay) { this._bodyA = ground; this._bodyB = this._box; this.la = new box2d.b2Vec2(); this.lb = new box2d.b2Vec2(); this._bodyA.toLocalPoint(this.la, new box2d.b2Vec2(this._box.x,this._box.y)); this._bodyB.toLocalPoint(this.lb, new box2d.b2Vec2(this._box.x,this._box.y)); this.xs = Math.cos(-40 * Math.PI / 180); this.ys = Math.sin(-40 * Math.PI / 180); this.xs = (this.xs * 1000)/1000; this.ys = (this.ys * 1000)/1000; this.joint = this.game.physics.box2d.prismaticJoint(this._bodyA,this._bodyB,ax,ay,this.la.x,this.la.y,this.lb.x,this.lb.y,0,0,false,low,up,true); this.joint.collideConnected = false; }; Jelly.prototype.enablePrimatic1 = function(xp,yp,ground,low,up,ax,ay) { this._bodyA = ground; this._bodyB = this._box; this.la = new box2d.b2Vec2(); this.lb = new box2d.b2Vec2(); this._bodyA.toLocalPoint(this.la, new box2d.b2Vec2(this._box.x,this._box.y)); this._bodyB.toLocalPoint(this.lb, new box2d.b2Vec2(this._box.x,this._box.y)); this.xs = Math.cos(-40 * Math.PI / 180); this.ys = Math.sin(-40 * Math.PI / 180); this.xs = (this.xs * 1000)/1000; this.ys = (this.ys * 1000)/1000; this.joint = this.game.physics.box2d.prismaticJoint(this._bodyA,this._bodyB,ax,ay,xp,yp,this.lb.x,this.lb.y,0,0,false,low,up,true); this.joint.collideConnected = false; }; Jelly.prototype.enableRevolute = function(ground,speed,torque,motor,low,up,limit) { this._bodyA = ground; this._bodyB = this._box; this.la = new box2d.b2Vec2(); this.lb = new box2d.b2Vec2(); this._bodyA.toLocalPoint(this.la, new box2d.b2Vec2(this._box.x,this._box.y)); this._bodyB.toLocalPoint(this.lb, new box2d.b2Vec2(this._box.x,this._box.y)); this.joint = this.game.physics.box2d.revoluteJoint(this._bodyA,this._bodyB,this.la.x,this.la.y,this.lb.x,this.lb.y,speed,torque,motor,low,up,limit); this.joint.collideConnected = false; }; Jelly.prototype.disableJoint = function() { if (this.joint) this.game.physics.box2d.world.DestroyJoint(this.joint); }; Jelly.prototype.disable = function() { this.disabled = true; for(var j=0;j 0) { this.bodyA = bodyArray[0]; this.bodyA.toLocalPoint(this.vAnchorA,new box2d.b2Vec2(joint[j].x, joint[j].y)); this.bodyB = bodyArray[1]; if(this.bodyA !== undefined && this.bodyB !== undefined ) { this.bodyB.toLocalPoint(this.vAnchorB,new box2d.b2Vec2(joint[j].x, joint[j].y)); this.game.physics.box2d.weldJoint(this.bodyA,this.bodyB);//this.vAnchorA.x,this.vAnchorA.y,this.vAnchorB.x,this.vAnchorB.y); } }*/ } }; Jelly.prototype._createJelly = function(map,object) { this._pop = this._findBod3("mid",map,object); this._addBox(); // this._createPoly(); switch(this._pop.ot) { case STAND: this._bodies = this._findPoly("bod",map,object); this.applyJelly(this._bodies); this._createBoxLink(this._bodies); this._createinnerLink(this._bodies); break; case GUM: this._bodies = this._findPoly("bod",map,object); this.applyJelly(this._bodies); this._createBoxLink(this._bodies); this._createinnerLink(this._bodies); this._link = this._findJoint("joint",map,object); this._createJointLink(this._link); break; case BRIDGE: this._bodies = this._findPoly("bod",map,object); this.applyJelly(this._bodies); this._createBoxLink(this._bodies); this._createinnerLink(this._bodies); this._link = this._findJoint("joint",map,object); this._createJointLink(this._link); break; case LIFT: this._bodies = this._findPoly("bod",map,object); this.applyJelly(this._bodies); this._createBoxLink(this._bodies); this._createinnerLink(this._bodies); this._link = this._findJoint("joint",map,object); this._createJointLink(this._link); break; case TRUCK: this._bodies = this._findPoly("bod",map,object); this.applyJelly(this._bodies); this._createBoxLink(this._bodies); this._createinnerLink(this._bodies); this._vbump = this._findbump("center",map,object); this._addBump(); this._createBumpLink(this._bodies); break; case CIRCLE: this._bodies = this._findPoly("bod",map,object); this.applyJelly(this._bodies); this._createBoxLink(this._bodies); this._createinnerLink(this._bodies); break; case BALLOON: this._bodies = this._findPoly("bod",map,object); this.applyJelly(this._bodies); this._createBoxLink(this._bodies); this._createinnerLink(this._bodies); this._vbump = this._findbump("center",map,object); this._addBump(); this._createBumpLink(this._bodies); break; case WHEEL: this._bodies = this._findPoly("bod",map,object); this.applyJelly(this._bodies); this._createBoxLink(this._bodies); this._createinnerLink(this._bodies); break; } }; Jelly.prototype.renderClose = function() { for(var j=0;j