Exemplo n.º 1
0
 public void UnbindPhysics(SpriteBatchObject o)
 {
     if (usePhysics)
     {
         PBody body = (PBody)CollectionUtils.Remove(_Bodys, o);
         if (body != null)
         {
             body.SetTag(null);
             _manager.world.RemoveBody(body);
         }
     }
 }
Exemplo n.º 2
0
 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 !");
     }
 }
Exemplo n.º 3
0
 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 !");
     }
 }
Exemplo n.º 4
0
 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 !");
     }
 }
Exemplo n.º 5
0
 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 !");
     }
 }