• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Dynamics.b2World类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Box2D.Dynamics.b2World的典型用法代码示例。如果您正苦于以下问题:C# b2World类的具体用法?C# b2World怎么用?C# b2World使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



b2World类属于Box2D.Dynamics命名空间,在下文中一共展示了b2World类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Enemy

        public Enemy(b2World world,
		              CCPoint location,
		              string spriteFileName,
		              bool isTheRotationFixed,
		              bool getsDamageFromGround,
		              bool doesGetDamageFromDamageEnabledStackObjects,
		              int breaksFromHowMuchContact,
		              bool hasDifferentSpritesForDamage,
		              int numberOfFramesToAnimateOnBreak,
		              float density,
		              CreationMethod createHow,
		              int points,
		              BreakEffect simpleScoreVisualFXType )
        {
            InitWithWorld( world,
                           location,
                           spriteFileName,
                           isTheRotationFixed,
                           getsDamageFromGround,
                           doesGetDamageFromDamageEnabledStackObjects,
                           breaksFromHowMuchContact,
                           hasDifferentSpritesForDamage,
                           numberOfFramesToAnimateOnBreak,
                           density,
                           createHow,
                           points,
                           simpleScoreVisualFXType );
        }
开发者ID:CasperWollesen,项目名称:AngryNinjas,代码行数:28,代码来源:Enemy.cs


示例2: InitStackWithWorld

        void InitStackWithWorld(b2World theWorld)
        {
            this.world = theWorld;

            if (TheLevel.SharedLevel.IS_IPAD)
            {
                stackLocationX = 1400;  //base X starting point for the entire stack on the iPad (make further tweaks using the  stackAdjustmentX var in the buildLevel function per level
                stackLocationY = 100; //base Y starting point for the entire stack on the iPad (make further tweaks using the  stackAdjustmentY var in the buildLevel function per level
            }
            else
            {

                stackLocationX = 900;  //base X starting point for the entire stack on the iPhone (make further tweaks using the  stackAdjustmentX var in the buildLevel function per level
                stackLocationY = 35; //base Y starting point for the entire stack on the iPhone (make further tweaks using the  stackAdjustmentY var in the buildLevel function per level
            }

            currentLevel = GameData.SharedData.Level;
            if (currentLevel % 2 == 0)
            {
                BuildLevel2();
            }
            else
            {
                BuildLevel1();
            }
        }
开发者ID:Karunp,项目名称:AngryNinjas,代码行数:26,代码来源:TheStack.cs


示例3: InitPhysics

        void InitPhysics()
        {
            var gravity = new b2Vec2(0.0f, -10.0f);
            world = new b2World(gravity);

            world.SetAllowSleeping(true);
            world.SetContinuousPhysics(true);

            var def = new b2BodyDef();
            def.allowSleep = true;
            def.position = b2Vec2.Zero;
            def.type = b2BodyType.b2_staticBody;

            b2Body groundBody = world.CreateBody(def);
            groundBody.SetActive(true);

            b2EdgeShape groundBox = new b2EdgeShape();
            groundBox.Set(b2Vec2.Zero, new b2Vec2(900, 100));

            b2FixtureDef fd = new b2FixtureDef();
            fd.friction = 0.3f;
            fd.restitution = 0.1f;
            fd.shape = groundBox;

            groundBody.CreateFixture(fd);
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:26,代码来源:IntroLayer.cs


示例4: MouseTouch

 public MouseTouch(b2World world, RubeBasicLayer layer)
 {
     parent = layer;
     m_world = world;
     b2BodyDef bodyDef = new b2BodyDef();
     m_groundBody = m_world.CreateBody(bodyDef);
 }
开发者ID:netonjm,项目名称:RubeLoader,代码行数:7,代码来源:MouseTouch.cs


示例5: JumpPad

        public JumpPad(b2Vec2 JumpImpuls, CCPoint Position, b2World gameWorld)
        {
            this.Texture = new CCTexture2D ("jumppad");
            this.Scale = SpriteScale;
            this.Position = Position;
            this.IsAntialiased = false;

            jumpImpuls = JumpImpuls;
            totalJumps = 0;

            //box2d
            b2BodyDef jumpPadDef = new b2BodyDef ();
            jumpPadDef.type = b2BodyType.b2_kinematicBody;
            jumpPadDef.position = new b2Vec2 ((Position.X + this.ScaledContentSize.Width/2)/PhysicsHandler.pixelPerMeter, (Position.Y + this.ScaledContentSize.Height/4) / PhysicsHandler.pixelPerMeter);
            JumpPadBody = gameWorld.CreateBody (jumpPadDef);

            b2PolygonShape jumpPadShape = new b2PolygonShape ();
            jumpPadShape.SetAsBox ((float)this.ScaledContentSize.Width / PhysicsHandler.pixelPerMeter / 2, (float)this.ScaledContentSize.Height / PhysicsHandler.pixelPerMeter / 4);// /4 weil die hitbox nur die hälfte der textur ist

            b2FixtureDef jumpPadFixture = new b2FixtureDef ();
            jumpPadFixture.shape = jumpPadShape;
            jumpPadFixture.density = 0.0f; //Dichte
            jumpPadFixture.restitution = 0f; //Rückprall
            jumpPadFixture.friction = 0f;
            jumpPadFixture.userData = WorldFixtureData.jumppad;
            JumpPadBody.CreateFixture (jumpPadFixture);
            //
        }
开发者ID:Nuckal777,项目名称:mapKnight,代码行数:28,代码来源:JumpPad.cs


示例6: InitWithWorld

		private void InitWithWorld( b2World world, CCPoint location, string spriteFileName)
		{
			this.theWorld = world;
			this.initialLocation = location;
			this.spriteImageName = spriteFileName;
			CreateGround();
		}
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:7,代码来源:GroundPlane.cs


示例7: StackObject

		public BreakEffect  SimpleScoreVisualFX { get; set; } //defined in Constants.cs

		public StackObject (b2World world, 
		                    CCPoint location,
		                    string spriteFileName,
		                    bool breaksOnGround,
		                    bool breaksFromNinja,
		                    bool hasAnimatedBreakFrames,
		                    bool damagesEnemy,
		                    float density,
		                    CreationMethod createHow,
		                    int angleChange,
		                    bool makeImmovable,
		                    int points,
		                    BreakEffect simpleScoreVisualFXType)
		{
			InitWithWorld(world, 
			              location, 
			              spriteFileName, 
			              breaksOnGround,
			              breaksFromNinja,
			              hasAnimatedBreakFrames,
			              damagesEnemy,
			              density,
			              createHow,
			              angleChange,
			              makeImmovable,
			              points,
			              simpleScoreVisualFXType);
		}
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:30,代码来源:StackObject.cs


示例8: InitWithWorld

        void InitWithWorld(b2World world,
                            CCPoint location,
                            string spriteFileName,
                            bool isTheRotationFixed,
                            bool getsDamageFromGround,
                            bool doesGetDamageFromDamageEnabledStackObjects,
                            int breaksFromHowMuchContact,
                            bool hasDifferentSpritesForDamage,
                            int numberOfFramesToAnimateOnBreak,
                            float density,
                            CreationMethod createHow,
                            int points,
                            BreakEffect simpleScoreVisualFXType)
        {
            this.theWorld = world;
            this.initialLocation = location;
            this.baseImageName = spriteFileName;
            this.spriteImageName = String.Format("{0}", baseImageName);

            this.DamagesFromGroundContact = getsDamageFromGround; // does the ground break / damage the enemy

            this.damageLevel = 0; //starts at 0, if breaksAfterHowMuchContact also equals 0 then the enemy will break on first/next contact
            this.breaksAfterHowMuchContact = breaksFromHowMuchContact; //contact must be made this many times before breaking, or if set to 0, the enemy will break on first/next contact 
            this.differentSpritesForDamage = hasDifferentSpritesForDamage; //will progress through damage frames if this is YES, for example,  enemy_damage1.png, enemy_damage2.png

            this.currentFrame = 0;
            this.framesToAnimateOnBreak = numberOfFramesToAnimateOnBreak;  //will animate through breaks frames if this is more than 0, for example,  enemy_break0001.png, enemy_break0002.png


            this.theDensity = density;
            this.shapeCreationMethod = createHow;

            this.isRotationFixed = isTheRotationFixed;

            this.PointValue = points;
            this.SimpleScoreVisualFX = simpleScoreVisualFXType;

            this.DamagesFromDamageEnabledStackObjects = doesGetDamageFromDamageEnabledStackObjects;


            if (damageLevel == breaksAfterHowMuchContact)
            {
                BreaksOnNextDamage = true;
            }
            else
            {
                BreaksOnNextDamage = false; //duh

            }


            CreateEnemy();


        }
开发者ID:headinthebox,项目名称:cocos-sharp-samples,代码行数:55,代码来源:Enemy.cs


示例9: InitWithWorld

		private void InitWithWorld (b2World world, CCPoint location, string baseFileName)
		{
			
			theWorld = world;
			initialLocation = location;
			baseImageName = baseFileName;
			
			
			//later we use initialLocation.x 
			
			CreateNinja();
		}
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:12,代码来源:Ninja.cs


示例10: CreateBodyWithSpriteAndFixture

        protected void CreateBodyWithSpriteAndFixture(b2World world, b2BodyDef bodyDef,
                                                       b2FixtureDef fixtureDef, string spriteName)
        {
            // this is the meat of our class, it creates (OR recreates) the body in the world with the body definition, fixture definition and sprite name

            RemoveBody(); //if remove the body if it already exists
            RemoveSprite(); //if remove the sprite if it already exists

            sprite = new CCSprite(spriteName);
            AddChild(sprite);

            body = world.CreateBody(bodyDef);
            body.UserData = this;

            if (fixtureDef != null)
                body.CreateFixture(fixtureDef);
        }
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:17,代码来源:BodyNode.cs


示例11: GameScene

        public GameScene(Game game)
        {
            this.game = game;
            // ��ʼ��world
            b2Vec2 gravity = new b2Vec2(0f, -20f);
            world = new b2World(gravity);
            world.AllowSleep = false;
            InitBack();
            AddBarLayer();

            InitScore();
            AddGround();
            AddBird();
            world.SetContactListener(new BirdContactListener(this, (CCSprite)(birdBody.UserData)));
            this.schedule(tick);

            SimpleAudioEngine.sharedEngine().playBackgroundMusic(@"musics/background", true);
        }
开发者ID:hj458377603,项目名称:FlappyBird,代码行数:18,代码来源:GameScene.cs


示例12: Initialize

        public void Initialize(float mapSizeWidth, Character Character, CCTileMapLayer physicsLayer, CCTileMap physicsMap, Container gameContainer)
        {
            mapSizeWidth /= pixelPerMeter;
            gameWorld = new b2World (new b2Vec2 (0, -9.8f));
            gameWorld.AllowSleep = false;

            //definiert den MainCharacter
            Character.createPhysicsBody (gameWorld);
            defineGround (mapSizeWidth);

            createBox2DWorldByLayer (physicsLayer, physicsMap);

            debugDrawer = new DebugDraw ();
            gameWorld.SetDebugDraw (debugDrawer);
            debugDrawer.AppendFlags (b2DrawFlags.e_shapeBit);

            collusionSensor = new CollusionSensor (gameContainer);
            gameWorld.SetContactListener (collusionSensor);
        }
开发者ID:Nuckal777,项目名称:mapKnight,代码行数:19,代码来源:Main.cs


示例13: Mouse

        public Mouse()
        {
            //m_destructionListener = new DestructionListener();
            m_debugDraw = new CCBox2dDraw("fonts/arial-16");

            b2Vec2 gravity = new b2Vec2();
            gravity.Set(500, 500);
           
            m_world = new b2World(gravity);

            
            m_world.SetAllowSleeping(false);
            m_world.SetContinuousPhysics(true);


            m_world.SetDebugDraw(m_debugDraw);
            m_debugDraw.AppendFlags(b2DrawFlags.e_shapeBit | b2DrawFlags.e_aabbBit | b2DrawFlags.e_centerOfMassBit | b2DrawFlags.e_jointBit | b2DrawFlags.e_pairBit);

            m_world.SetContinuousPhysics(true);
            m_world.SetWarmStarting(true);
        }
开发者ID:netonjm,项目名称:Rube.Net,代码行数:21,代码来源:Mouse.cs


示例14: BoxProp

        public BoxProp(
               b2World b2world,

             double[] size,
             double[] position

            )
        {
            /*
            static rectangle shaped prop
     
                pars:
                size - array [width, height]
                position - array [x, y], in world meters, of center
            */
            this.size = size;

            //initialize body
            var bdef = new b2BodyDef();
            bdef.position = new b2Vec2(position[0], position[1]);
            bdef.angle = 0;
            bdef.fixedRotation = true;
            this.body = b2world.CreateBody(bdef);

            //initialize shape
            var fixdef = new b2FixtureDef();

            var shape = new b2PolygonShape();
            fixdef.shape = shape;

            shape.SetAsBox(this.size[0] / 2, this.size[1] / 2);

            fixdef.restitution = 0.4; //positively bouncy!



            this.body.CreateFixture(fixdef);
        }
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:38,代码来源:BoxProp.cs


示例15: InitWithWorld

		void InitWithWorld(b2World world, 
		                   CCPoint location,
		                   string spriteFileName,
		                   bool breaksOnGround,
		                   bool breaksFromNinja,
		                   bool hasAnimatedBreakFrames,
		                   bool damagesEnemy,
		                   float density,
		                   CreationMethod createHow,
		                   int angleChange,
		                   bool makeImmovable,
		                   int points,
		                   BreakEffect simpleScoreVisualFXType)
		{
			this.theWorld = world;
			this.initialLocation = location;
			this.baseImageName = spriteFileName;
			this.spriteImageName =  String.Format("{0}", baseImageName);
			
			this.IsBreaksOnGroundContact = breaksOnGround; 
			this.IsBreaksOnNinjaContact = breaksFromNinja; 
			this.addedAnimatedBreakFrames = hasAnimatedBreakFrames;
			this.IsCanDamageEnemy = damagesEnemy;
			this.theDensity = density;
			this.shapeCreationMethod = createHow;
			this.angle = angleChange;
			this.IsStatic = makeImmovable;
			
			this.currentFrame = 0;
			this.framesToAnimate = 10;
			
			this.PointValue = points ;
			this.SimpleScoreVisualFX = simpleScoreVisualFXType;
			
			CreateObject();
				
		}
开发者ID:460189852,项目名称:cocos-sharp-samples,代码行数:37,代码来源:StackObject.cs


示例16: GroundPlane

		public GroundPlane (b2World world, CCPoint location, string spriteFileName )
		{
			InitWithWorld(world, location, spriteFileName);
		}
开发者ID:headinthebox,项目名称:cocos-sharp-samples,代码行数:4,代码来源:GroundPlane.cs


示例17: ApplicationSprite

        public ApplicationSprite()
        {

            #region AtInitializeConsoleFormWriter

            var w = new __OutWriter();
            var o = Console.Out;
            var __reentry = false;

            var __buffer = new StringBuilder();

            w.AtWrite =
                x =>
                {
                    __buffer.Append(x);
                };

            w.AtWriteLine =
                x =>
                {
                    __buffer.AppendLine(x);
                };

            Console.SetOut(w);

            this.AtInitializeConsoleFormWriter = (
                Action<string> Console_Write,
                Action<string> Console_WriteLine
            ) =>
            {

                try
                {


                    w.AtWrite =
                        x =>
                        {
                            o.Write(x);

                            if (!__reentry)
                            {
                                __reentry = true;
                                Console_Write(x);
                                __reentry = false;
                            }
                        };

                    w.AtWriteLine =
                        x =>
                        {
                            o.WriteLine(x);

                            if (!__reentry)
                            {
                                __reentry = true;
                                Console_WriteLine(x);
                                __reentry = false;
                            }
                        };

                    Console.WriteLine("flash Console.WriteLine should now appear in JavaScript form!");
                    Console.WriteLine(__buffer.ToString());
                }
                catch
                {

                }
            };
            #endregion




            var SCALE = 15;      //how many pixels in a meter
            var WIDTH_M = DefaultWidth / SCALE; //world width in meters. for this example, world is as large as the screen
            var HEIGHT_M = DefaultHeight / SCALE; //world height in meters

            //initialize font to draw text with
            //var font=new gamejs.font.Font('16px Sans-serif');

            //key bindings
            //var BINDINGS={accelerate:gamejs.event.K_UP, 
            //              brake:gamejs.event.K_DOWN,      
            //              steer_left:gamejs.event.K_LEFT, 
            //               steer_right:gamejs.event.K_RIGHT}; 









            //initialize display
            //var display = gamejs.display.setMode([WIDTH_PX, HEIGHT_PX]);

            //SET UP B2WORLD
            var b2world = new b2World(new b2Vec2(0, 0), false);
//.........这里部分代码省略.........
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:101,代码来源:ApplicationSprite.cs


示例18: Car

            public Car(
                b2World b2world,

                double width,
                double length,
                double[] position,
                double angle,
                double power,
                double max_steer_angle,
                double max_speed,
                Wheel[] wheels
                )
            {
                //        /*
                //        pars is an object with possible attributes:

                //        width - width of the car in meters
                //        length - length of the car in meters
                //        position - starting position of the car, array [x, y] in meters
                //        angle - starting angle of the car, degrees
                //        max_steer_angle - maximum angle the wheels turn when steering, degrees
                //        max_speed       - maximum speed of the car, km/h
                //        power - engine force, in newtons, that is applied to EACH powered wheel
                //        wheels - wheel definitions: [{x, y, rotatable, powered}}, ...] where
                //                 x is wheel position in meters relative to car body center
                //                 y is wheel position in meters relative to car body center
                //                 revolving - boolean, does this turn rotate when steering?
                //                 powered - is force applied to this wheel when accelerating/braking?
                //        */



                //        this.max_steer_angle=pars.max_steer_angle;
                //        this.max_speed=pars.max_speed;
                //        this.power=pars.power;
                var wheel_angle = 0.0;//keep track of current wheel angle relative to car.
                //                           //when steering left/right, angle will be decreased/increased gradually over 200ms to prevent jerkyness.

                //initialize body
                var def = new b2BodyDef();
                def.type = b2Body.b2_dynamicBody;
                def.position = new b2Vec2(position[0], position[1]);
                def.angle = angle.DegreesToRadians();
                def.linearDamping = 0.15;  //gradually reduces velocity, makes the car reduce speed slowly if neither accelerator nor brake is pressed
                def.bullet = true; //dedicates more time to collision detection - car travelling at high speeds at low framerates otherwise might teleport through obstacles.
                def.angularDamping = 0.3;

                this.body = b2world.CreateBody(def);

                //initialize shape
                var fixdef = new b2FixtureDef();
                fixdef.density = 1.0;
                fixdef.friction = 0.3; //friction when rubbing agaisnt other shapes
                fixdef.restitution = 0.4;  //amount of force feedback when hitting something. >0 makes the car bounce off, it's fun!

                var fixdef_shape = new b2PolygonShape();

                fixdef.shape = fixdef_shape;
                fixdef_shape.SetAsBox(width / 2, length / 2);
                body.CreateFixture(fixdef);

                //initialize wheels
                foreach (var item in wheels)
                {
                    item.Initialize(this);
                }

                //return array of wheels that turn when steering
                IEnumerable<Wheel> getRevolvingWheels = from w in wheels where w.revolving select w;
                //        //return array of powered wheels
                IEnumerable<Wheel> getPoweredWheels = from w in wheels where w.powered select w;

                #region setSpeed
                Action<double> setSpeed = (speed) =>
                {
                    /*
                    speed - speed in kilometers per hour
                    */
                    var velocity0 = this.body.GetLinearVelocity();

                    //Console.WriteLine("car setSpeed velocity0 " + new { velocity0.x, velocity0.y });

                    var velocity2 = vectors.unit(new[] { velocity0.x, velocity0.y });

                    //Console.WriteLine("car setSpeed velocity2 " + new { x = velocity2[0], y = velocity2[1] });
                    var velocity = new b2Vec2(
                        velocity2[0] * ((speed * 1000.0) / 3600.0),
                        velocity2[1] * ((speed * 1000.0) / 3600.0)
                    );

                    //Console.WriteLine("car setSpeed SetLinearVelocity " + new { velocity.x, velocity.y });
                    this.body.SetLinearVelocity(velocity);

                };
                #endregion


                #region getSpeedKMH
                Func<double> getSpeedKMH = delegate
                {
//.........这里部分代码省略.........
开发者ID:exaphaser,项目名称:JSC-Cross-Compiler,代码行数:101,代码来源:ApplicationSprite.cs


示例19: initPhysics

        private void initPhysics()
        {
            CCSize s = CCDirector.SharedDirector.WinSize;

            var gravity = new b2Vec2(0.0f, -10.0f);
            _world = new b2World(gravity);
            float debugWidth = s.Width / PTM_RATIO * 2f;
            float debugHeight = s.Height / PTM_RATIO * 2f;
            CCDraw debugDraw = new CCDraw(new b2Vec2(debugWidth / 2f + 10, s.Height - debugHeight - 10), 2);
            debugDraw.AppendFlags(b2DrawFlags.e_shapeBit);
            _world.SetDebugDraw(debugDraw);
            _world.SetAllowSleeping(true);
            _world.SetContinuousPhysics(true);

            //m_debugDraw = new GLESDebugDraw( PTM_RATIO );
            //world->SetDebugDraw(m_debugDraw);

            //uint32 flags = 0;
            //flags += b2Draw::e_shapeBit;
            //        flags += b2Draw::e_jointBit;
            //        flags += b2Draw::e_aabbBit;
            //        flags += b2Draw::e_pairBit;
            //        flags += b2Draw::e_centerOfMassBit;
            //m_debugDraw->SetFlags(flags);


            // Call the body factory which allocates memory for the ground body
            // from a pool and creates the ground box shape (also from a pool).
            // The body is also added to the world.
            b2BodyDef def = b2BodyDef.Create();
            def.allowSleep = true;
            def.position = b2Vec2.Zero;
            def.type = b2BodyType.b2_staticBody;
            b2Body groundBody = _world.CreateBody(def);
            groundBody.SetActive(true);

            // Define the ground box shape.

            // bottom
            b2EdgeShape groundBox = new b2EdgeShape();
            groundBox.Set(b2Vec2.Zero, new b2Vec2(s.Width / PTM_RATIO, 0));
            b2FixtureDef fd = b2FixtureDef.Create();
            fd.shape = groundBox;
            groundBody.CreateFixture(fd);

            // top
            groundBox = new b2EdgeShape();
            groundBox.Set(new b2Vec2(0, s.Height / PTM_RATIO), new b2Vec2(s.Width / PTM_RATIO, s.Height / PTM_RATIO));
            fd.shape = groundBox;
            groundBody.CreateFixture(fd);

            // left
            groundBox = new b2EdgeShape();
            groundBox.Set(new b2Vec2(0, s.Height / PTM_RATIO), b2Vec2.Zero);
            fd.shape = groundBox;
            groundBody.CreateFixture(fd);

            // right
            groundBox = new b2EdgeShape();
            groundBox.Set(new b2Vec2(s.Width / PTM_RATIO, s.Height / PTM_RATIO), new b2Vec2(s.Width / PTM_RATIO, 0));
            fd.shape = groundBox;
            groundBody.CreateFixture(fd);

            // _world.Dump();
        }
开发者ID:pekayatt,项目名称:cocos2d-xna,代码行数:65,代码来源:Box2DTest.cs


示例20: b2Body

        protected b2Transform m_xf = b2Transform.Default; // the body origin transform

        #endregion Fields

        #region Constructors

        public b2Body(b2BodyDef bd, b2World world)
        {
            m_flags = 0;

            if (bd.bullet)
            {
                m_flags |= b2BodyFlags.e_bulletFlag;
            }
            if (bd.fixedRotation)
            {
                m_flags |= b2BodyFlags.e_fixedRotationFlag;
            }
            if (bd.allowSleep)
            {
                m_flags |= b2BodyFlags.e_autoSleepFlag;
            }
            if (bd.awake)
            {
                m_flags |= b2BodyFlags.e_awakeFlag;
            }
            if (bd.active)
            {
                m_flags |= b2BodyFlags.e_activeFlag;
            }

            m_world = world;

            m_xf.p = bd.position;
            m_xf.q.Set(bd.angle);

            Sweep.localCenter.SetZero();
            Sweep.c0 = m_xf.p;
            Sweep.c = m_xf.p;
            Sweep.a0 = bd.angle;
            Sweep.a = bd.angle;
            Sweep.alpha0 = 0.0f;

            m_jointList = null;
            m_contactList = null;
            Prev = null;
            Next = null;

            m_linearVelocity = bd.linearVelocity;
            m_angularVelocity = bd.angularVelocity;

            m_linearDamping = bd.linearDamping;
            m_angularDamping = bd.angularDamping;
            m_gravityScale = bd.gravityScale;

            m_force.SetZero();
            m_torque = 0.0f;

            m_sleepTime = 0.0f;

            m_type = bd.type;

            if (m_type == b2BodyType.b2_dynamicBody)
            {
                m_mass = 1.0f;
                m_invMass = 1.0f;
            }
            else
            {
                m_mass = 0.0f;
                m_invMass = 0.0f;
            }

            m_I = 0.0f;
            m_invI = 0.0f;

            m_userData = bd.userData;

            m_fixtureList = null;
            m_fixtureCount = 0;
        }
开发者ID:homocury,项目名称:cocos2d-xna,代码行数:81,代码来源:b2Body.cs



注:本文中的Box2D.Dynamics.b2World类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Common.Vec2类代码示例发布时间:2022-05-24
下一篇:
C# Dynamics.b2FixtureDef类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap