public IBody CreateBody(Blob blob, float radius, float mass, bool isStatic) { lock (UpdateLock) { var body = isStatic ? cpBody.NewStatic() : cpBody.New(mass, float.PositiveInfinity); body.SetUserData(blob); var shape = new cpCircleShape(body, radius, cpVect.Zero); shape.SetCollisionType(GenerateCollisionType(blob.GetType())); lock (ShapesListLock) { _shapesToAdd.Add(shape); } if (_space.IsLocked) { _space.AddPostStepCallback(OnPostStep, null, null); } else { AddShapes(); } _reindexStatic |= isStatic; return(new ChipmunkBody(shape, isStatic)); } }
public PhysicObject(UIImage firstText, int radius, cpSpace space, bool isKinematic = false) : base(firstText) { trsf = new cpTransform(); collCount++; physic = new cpBody(rnd.Next(500, 1000), cp.PHYSICS_INFINITY); if (isKinematic) { physic.SetBodyType(cpBodyType.KINEMATIC); } shp = new cpCircleShape(physic, radius, cpVect.Zero); shp.Active(); shp.SetSensor(true); shp.SetCollisionType(1); physic.SetPosition(new cpVect((float)Frame.Location.X, (float)Frame.Location.Y)); if (space != null) { space.AddBody(physic); space.AddShape(shp); this.space = space; } }