コード例 #1
0
ファイル: Body.cs プロジェクト: prepare/box2c
        /// <summary>
        /// Attach a fixture to this shape.
        /// </summary>
        /// <param name="def">The fixture definition to add.</param>
        /// <returns>The created Fixture object.</returns>
        public Fixture CreateFixture(FixtureDef def)
        {
            def.SetShape(def.Shape.Lock());
            Fixture fixture;

            using (var structPtr = new StructToPtrMarshaller(def.Internal))
                fixture = Fixture.FromPtr(NativeMethods.b2body_createfixture(_bodyPtr, structPtr.Pointer));
            def.Shape.Unlock();
            return(fixture);
        }
コード例 #2
0
 public Joint CreateJoint(JointDef def)
 {
     using (var ptr = new StructToPtrMarshaller(def))
         return(Joint.FromPtr(NativeMethods.b2world_createjoint(_worldPtr, ptr.Pointer)));
 }
コード例 #3
0
 public Body CreateBody(BodyDef def)
 {
     using (var structPtr = new StructToPtrMarshaller(def))
         return(Body.FromPtr(NativeMethods.b2world_createbody(_worldPtr, structPtr.Pointer)));
 }
コード例 #4
0
 internal override void Unlock()
 {
     _internalstruct.Free();
     _internalstruct = null;
 }
コード例 #5
0
 internal override IntPtr Lock()
 {
     _internalCircleShape.m_shape = base.InternalShape;
     _internalstruct = new StructToPtrMarshaller(_internalCircleShape);
     return(_internalstruct.Pointer);
 }