Exemplo n.º 1
0
        /// <summary>
        /// Creates a new PhysicsComponent.
        /// </summary>
        /// <param name="id">The ID of the PhysicsComponent.</param>
        /// <param name="bounds">The bounding area of the PhysicsComponent.</param>
        /// <param name="acceleration">The initial acceleration of the PhysicsComponent.</param>
        /// <param name="mass">The mass of the PhysicsComponent.</param>
        public PhysicsComponent(string id, Rectangle bounds,
                                Vector2 acceleration, float mass)
            : base(id)
        {
            collisionObject = new CollisionObject(id + "Collide", bounds);
            collisionObject.SetAttachedTo(ID);

            particlePhysics = new ParticleObject(new Vector2(bounds.Center.X,
                                                             bounds.Center.Y), acceleration, mass);

            particlePhysics.AttachedToID = collisionObject.ID;

            particlePhysics.OnUpdate   += new OnParticleUpdateEvent(ParticleUpdate);
            collisionObject.OnCollided += new CollisionEvent(Collided);
        }