public void UnbindPhysics(SpriteBatchObject o) { if (usePhysics) { PBody body = (PBody)CollectionUtils.Remove(_Bodys, o); if (body != null) { body.SetTag(null); _manager.world.RemoveBody(body); } } }
public PBody BindPhysics(PBody body, SpriteBatchObject o) { if (usePhysics) { body.SetTag(o); _manager.AddBody(body); CollectionUtils.Put(_Bodys, o, body); return(body); } else { throw new RuntimeException("You do not set the physics engine !"); } }
public PBody BindPhysics(bool fix, SpriteBatchObject o, float density) { if (usePhysics) { PBody body = _manager.AddBox(fix, o.GetRectBox(), MathUtils.ToRadians(o.GetRotation()), density); body.SetTag(o); CollectionUtils.Put(_Bodys, o, body); return(body); } else { throw new RuntimeException("You do not set the physics engine !"); } }
public PBody BindCirclePhysics(bool fix, SpriteBatchObject o, float density) { if (usePhysics) { RectBox rect = o.GetRectBox(); float r = (rect.width + rect.height) / 4; PBody body = _manager.AddCircle(fix, o.X(), o.Y(), r, MathUtils.ToRadians(o.GetRotation()), density); body.SetTag(o); CollectionUtils.Put(_Bodys, o, body); return(body); } else { throw new RuntimeException("You do not set the physics engine !"); } }
public PBody BindTexturePhysics(bool fix, SpriteBatchObject o, float density) { if (usePhysics) { PBody body = _manager.AddShape(fix, o.GetAnimation() .GetSpriteImage(), MathUtils.ToRadians(o.GetRotation()), density); if (body.Size() > 0) { body.Inner_shapes()[0].SetPosition(o.X() / _manager.scale, o.Y() / _manager.scale); } body.SetTag(o); CollectionUtils.Put(_Bodys, o, body); return(body); } else { throw new RuntimeException("You do not set the physics engine !"); } }