public override void Start()
        {
            //Kick off one message -- it'll get physics going on this screen.
            Switchboard.Instance.Broadcast(new Message("ScreenStarted"));

            //Add the ground actor so they'll have something to bounce off.
            p3 = new PhysicsActor();
            p3.Position = new Vector2(0.0f, -11.0f);
            p3.Size = new Vector2(30.0f, 5.0f);
            p3.Color = new Color(0.0f, 1.0f, 0.0f);
            p3.Density = 0.0f;
            p3.Friction = 0.1f;

            World.Instance.Add(p3);

            //Demo housekeeping below this point.
            #region Demo Housekeeping
            String outputText = "These actors are responding to Messages\nthat we're sending through our central Switchboard.";
            outputText += "\n\nYou can have actors respond to and broadcast arbitrary messages,\nwhich makes it easy to handle events in your game.";
            outputText += "\n\n\n(Those actors have been hanging out up there this whole time,\nwaiting for the message that this screen had started\nbefore they dropped in.)";
            t1 = new TextActor("Console", outputText);
            t1.Position = new Vector2(0.0f, 3.5f);
            t1.TextAlignment = TextActor.Alignment.Center;
            World.Instance.Add(t1);
            TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenMessagePassing.cs");
            fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755);
            fileLoc.Color = new Color(.3f, .3f, .3f);
            World.Instance.Add(fileLoc);
            _objects.Add(fileLoc);
            _objects.Add(t1);
            _objects.Add(p1);
            _objects.Add(p2);
            _objects.Add(p3);
            #endregion
        }
        public override void Start()
        {
            p1 = new PhysicsActor();
            //PhysicsActors have all the same attributes as regular ones...
            p1.Size = Vector2.One;
            p1.Color = new Color(1.0f, 0.0f, 1.0f, 1.0f);

            //...but with a little bit of magic pixie dust
            p1.Density = 0.8f; //density (0.0f will make it an immovable object)
            p1.Friction = 0.5f;
            p1.Restitution = 0.7f;

            p2 = new PhysicsActor();
            p2.Position = new Vector2(0.0f, -11.0f);
            p2.Size = new Vector2(30.0f, 5.0f);
            p2.Color = new Color(0.0f, 1.0f, 0.0f, 1.0f);
            p2.Density = 0.0f;
            p2.Friction = 0.1f;

            //NOTE: After you call InitPhysics (or the world calls it automatically), you
            // can't directly set an Actor's position, or rotation -- you've turned those
            // over to the physics engine. You can't change the size, either, since that
            // would mess up the simulation.

            World.Instance.Add(p1);
            World.Instance.Add(p2);

            //Demo housekeeping below this point.
            #region Demo Housekeeping
            t1 = new TextActor("Console", "These Actors use physics. Press [B].");
            t1.Position = new Vector2(0.0f, 3.5f);
            t1.TextAlignment = TextActor.Alignment.Center;
            World.Instance.Add(t1);
            TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenPhysicsActor.cs");
            fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755);
            fileLoc.Color = new Color(.3f, .3f, .3f);
            World.Instance.Add(fileLoc);
            _objects.Add(fileLoc);
            _objects.Add(t1);
            _objects.Add(p1);
            _objects.Add(p2);
            #endregion
        }
        public override void Start()
        {
            //Set up the PhysicsActors to collide
            p1 = new PhysicsActor();
            p1.Size = new Vector2(1.0f, 1.0f);
            p1.Color = new Color(1.0f, 0.0f, 1.0f, 1.0f);
            p1.Density = 0.8f;
            p1.Friction = 0.5f;
            p1.Restitution = 0.7f;

            // Unlike in Angel 1.1 (which uses a global OnCollision handler) here, we
            // register with the pieces we want to know about collisions from
            p1.Collision += new CollisionHandler(OnCollision);

            p2 = new PhysicsActor();
            p2.Position = new Vector2(0.0f, -11.0f);
            p2.Size = new Vector2(30.0f, 5.0f);
            p2.Color = new Color(0.0f, 1.0f, 0.0f);
            p2.Density = 0.0f;
            p2.Friction = 0.1f;

            World.Instance.Add(p1);
            World.Instance.Add(p2);

            //Demo housekeeping below this point.
            #region Demo housekeeping
            t1 = new TextActor("Console", "This example looks similar, but is responding to collisions with sound.");
            t1.Position = new Vector2(0.0f, 3.5f);
            t1.TextAlignment = TextActor.Alignment.Center;
            World.Instance.Add(t1);
            TextActor fileLoc = new TextActor("ConsoleSmall", "DemoScreenCollisions.cs");
            fileLoc.Position = World.Instance.Camera.ScreenToWorld(5, 755);
            fileLoc.Color = new Color(.3f, .3f, .3f);
            World.Instance.Add(fileLoc);
            _objects.Add(fileLoc);
            _objects.Add(t1);
            _objects.Add(p1);
            _objects.Add(p2);
            #endregion
        }
        internal override void OnCollision(PhysicsActor otherActor, ref ContactPoint point)
        {
            if (otherActor is PhysicsEventActor)
            {
                AddCollision((PhysicsEventActor)otherActor);
            }

            base.OnCollision(otherActor, ref point);
        }
        private void Setup()
        {
            //Create a new physics actor, but don't initialize its physics just yet. We'll start
            // physics in response to some messages later on.
            p1 = new PhysicsActor();
            p1.Size = new Vector2(1.0f, 1.0f);
            p1.Color = new Color(1.0f, 0.0f, 1.0f);
            p1.Position = new Vector2(-8.0f, 12.6f);
            p1.Rotation = 5.0f;
            p1.AutoInitPhysics = false;  // Don't initialize physics when the object is added to the world.

            //Make a friend for him, and don't initialize its physics when it gets added to the world.
            p2 = new PhysicsActor();
            p2.Size = new Vector2(1.0f, 1.0f);
            p2.Color = new Color(0.0f, 0.0f, 1.0f);
            p2.Position = new Vector2(8.0f, 12.6f);
            p2.AutoInitPhysics = false;

            //Add them all to the world. When we add them they are assigned names, which are
            // guaranteed to be unique. You can also assign your own name to any Actor with
            // SetName(), which returns the unique name it was actually given. (Numbers will
            // be appended if the name was already taken.)
            //
            //There's also a static function Actor::GetNamed() that you pass a string name
            // and will return either the Actor with that name or NULL.
            World.Instance.Add(p1);
            World.Instance.Add(p2);

            //This message is interesting -- all collision messages take the form "CollisionWith"
            // plus the name of the actor colliding. Note that this means if you change the name
            // of the actor, you need to change your subscriptions if you want to hear about
            // collisions.
            Switchboard.Instance["CollisionWith" + p1.Name] += new MessageHandler(ReceiveMessage);
            Switchboard.Instance["CollisionWith" + p2.Name] += new MessageHandler(ReceiveMessage);
        }
 private void OnCollision(PhysicsActor actorA, PhysicsActor actorB, ref Box2D.ContactPoint point)
 {
     if(Math.Abs(p1.Body.LinearVelocity.Y) > 5.0f)
         sound.Play();
 }
 internal virtual void OnCollision(PhysicsActor otherActor, ref ContactPoint point)
 {
     if (Collision != null)
         Collision(this, otherActor, ref point);
 }