addBody() private method

Add a rigid body.
private addBody ( Body body ) : void
body Body
return void
Ejemplo n.º 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
        }
Ejemplo n.º 2
0
Archivo: Body.cs Proyecto: prime31/Nez
		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
		}