addBody() private méthode

Add a rigid body.
private addBody ( Body body ) : void
body Body
Résultat void
Exemple #1
0
        public Body(World world, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userdata = null)
        {
            fixtureList = new List <Fixture>();
            bodyId      = _bodyIdCounter++;

            _world           = world;
            _enabled         = true;
            _awake           = true;
            _sleepingAllowed = true;

            userData      = userdata;
            gravityScale  = 1.0f;
            this.bodyType = bodyType;

            _xf.q.Set(rotation);

            //FPE: optimization
            if (position != Vector2.Zero)
            {
                _xf.p     = position;
                _sweep.C0 = _xf.p;
                _sweep.C  = _xf.p;
            }

            //FPE: optimization
            if (rotation != 0)
            {
                _sweep.A0 = rotation;
                _sweep.A  = rotation;
            }

            world.addBody(this);               //FPE note: bodies can't live without a World
        }
Exemple #2
0
		public Body( World world, Vector2 position = new Vector2(), float rotation = 0, BodyType bodyType = BodyType.Static, object userdata = null )
		{
			fixtureList = new List<Fixture>();
			bodyId = _bodyIdCounter++;

			_world = world;
			_enabled = true;
			_awake = true;
			_sleepingAllowed = true;

			userData = userdata;
			gravityScale = 1.0f;
			this.bodyType = bodyType;

			_xf.q.Set( rotation );

			//FPE: optimization
			if( position != Vector2.Zero )
			{
				_xf.p = position;
				_sweep.C0 = _xf.p;
				_sweep.C = _xf.p;
			}

			//FPE: optimization
			if( rotation != 0 )
			{
				_sweep.A0 = rotation;
				_sweep.A = rotation;
			}

			world.addBody( this ); //FPE note: bodies can't live without a World
		}