当前位置: 首页>>代码示例>>C#>>正文


C# Dynamics.b2World类代码示例

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


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


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