Example #1
0
 public void BeginContact(Contact contact, Body2dComponent other)
 {
     Log.Debug($"Body2dComponent BeginContact");
     try
     {
         OnBeginContactAction?.Invoke(other);
     }
     catch (System.Exception e)
     {
         Log.Error(e);
     }
 }
Example #2
0
        public Body CreateBoxCollider(Body2dComponent component, float x, float y, float hx, float hy)
        {
            var bd = new BodyDef
            {
                BodyType = BodyType.DynamicBody,
                Position = new Vector2(x, y)
            };
            var body = World.CreateBody(bd);

            body.IsBullet = false;
            var shape = new PolygonShape();

            shape.SetAsBox(hx, hy, Vector2.Zero, 0);
            body.CreateFixture(shape, 1.0f);
            body.UserData = component;

            bodyComponents.Add(body, component);
            return(body);
        }