File size: 3,739 Bytes
ca81e93 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
function JellyPeace(game,x,y,density,friction,bounce,adamp,ldamp,sen,sta,colb,colm,poly,inx,type,gravity,bullet)
{
this.game = game;
this._body = new Phaser.Physics.Box2D.Body(game,null,x,y,2);
this._body.setPolygon(poly);
this._body.mass = density;
this._body.friction = friction;
this._body.restitution = bounce;
this._body.linearDamping = ldamp;
this._body.angularDampiong =adamp;
this._body.fixedRotation = false
this._body.bullet = bullet;
this._body.gravityScale = gravity;
/* this.stredx = (poly[0] + poly[4])/2;
this.stredy =(poly[1] + poly[5])/2;
this.delx = this.stredx - this._body.x;
this.dely = this.stredy - this._body.y;
this.beta = Math.atan(this.dely / this.delx);
if (this.delx < 0)
{
this.beta += Math.PI;
}*/
this._body.sensor = sen;
this._body.static = false;//sta;
this.sopjene = false;
/* this._pA = new box2d.b2Vec2();
this._pB = new box2d.b2Vec2();
this._pC = new box2d.b2Vec2();
this._pD = new box2d.b2Vec2();*/
this.type = type;
this._body.setCollisionCategory(colb);
this._body.setCollisionMask(colm);
if(inx !==0)
for (var f = this._body.data.GetFixtureList(); f; f = f.GetNext())
{
var filter = f.GetFilterData();
filter.groupIndex = inx;
}
this._body.data.allowSleep = true;
this._body.data.SetAwake(false);
};
JellyPeace.prototype.update = function(xp,yp) {
/* for (var f = this._body.data.GetFixtureList(); f; f = f.GetNext())
{
var v = f.GetShape();
//console.log(v.m_vertices);
//if(v.GetVertexCount>=4)
{
// alert(v.GetVertexCount);
this.setA(this._body.x-this.game.physics.box2d.mpx(v.m_vertices[0].x),this._body.y-this.game.physics.box2d.mpx(v.m_vertices[0].y));
this.setB(this._body.x-this.game.physics.box2d.mpx(v.m_vertices[1].x),this._body.y-this.game.physics.box2d.mpx(v.m_vertices[1].y));
this.setC(this._body.x-this.game.physics.box2d.mpx(v.m_vertices[2].x),this._body.y-this.game.physics.box2d.mpx(v.m_vertices[2].y));
this.setD(this._body.x-this.game.physics.box2d.mpx(v.m_vertices[3].x),this._body.y-this.game.physics.box2d.mpx(v.m_vertices[3].y));
}
}*/
};
JellyPeace.prototype.setIndex = function(inx)
{
for (var f = this._body.data.GetFixtureList(); f; f = f.GetNext())
{
var filter = f.GetFilterData();
filter.groupIndex = inx;
}
};
JellyPeace.prototype.setSpojene = function(val)
{
this.sopjene = val;
};
JellyPeace.prototype.getSpojene = function()
{
return this.sopjene;
};
JellyPeace.prototype.getBeta = function()
{
return this.beta;
};
JellyPeace.prototype.getX = function()
{
return this._body.x;
};
JellyPeace.prototype.getY = function()
{
return this._body.y;
};
JellyPeace.prototype.destroy = function(game)
{
if(this._body!=null)
game.physics.box2d.world.DestroyBody(this._body);
};
JellyPeace.prototype.getBody = function()
{
return this._body;
};
/*JellyPeace.prototype.getA = function()
{
return this._pA;
};
JellyPeace.prototype.getB = function()
{
return this._pB;
};
JellyPeace.prototype.getC = function()
{
return this._pC;
};
JellyPeace.prototype.getD = function()
{
return this._pD;
};
JellyPeace.prototype.setA = function(x,y) {
this._pA.x = x;
this._pA.y = y;
};
JellyPeace.prototype.setB = function(x,y) {
this._pB.x = x;
this._pB.y = y;
};
JellyPeace.prototype.setC = function(x,y) {
this._pC.x = x;
this._pC.y = y;
};
JellyPeace.prototype.setD = function(x,y) {
this._pD.x = x;
this._pD.y = y;
};*/
|