HTML and CSS Reference
In-Depth Information
this.entity.bind('removed',this,'removed');
},
position: function(x,y) {
var stage = this.entity.parent;
this._body.SetAwake(true);
this._body.SetPosition(new B2d.Vec(x / stage.world.scale,
y / stage.world.scale));
},
angle: function(angle) {
this._body.SetAngle(angle / 180 * Math.PI);
},
velocity: function(x,y) {
var stage = this.entity.parent;
this._body.SetAwake(true);
this._body.SetLinearVelocity(new B2d.Vec(x / stage.world.scale,
y / stage.world.scale));
},
inserted: function() {
var entity = this.entity,
stage = entity.parent,
scale = stage.world.scale,
p = entity.p,
ops = entityDefaults,
def = this._def = new B2d.BodyDef,
fixtureDef = this._fixture = new B2d.FixtureDef;
def.position.x = p.x / scale;
def.position.y = p.y / scale;
def.type = p.type == 'static' ?
B2d.Body.b2_staticBody :
B2d.Body.b2_dynamicBody;
def.active = true;
this._body = stage.world.createBody(def);
this._body.SetUserData(entity);
fixtureDef.density = p.density || ops.density;
fixtureDef.friction = p.friction || ops.friction;
fixtureDef.restitution = p.restitution || ops.restitution;
switch(p.shape) {
case "block":
fixtureDef.shape = new B2d.PolygonShape;
fixtureDef.shape.SetAsBox(p.w/2/scale, p.h/2/scale);
break;
case "circle":
Search WWH ::




Custom Search