public FallDude() { SetSpriteFromFile("fallGuy"); fallRect = new Rect(new Vector2(20, 35), new Vector2(random.Next(1, Game1.Instance.GraphicsDevice.Viewport.Width), -50)); position = fallRect.position; myCDR = CollisionWorld.Instance.AddDelegate(CollisionWorld.CollisionGroupIdentifier.Faller, new CollisionDelegate(null, fallRect)); fallSpeed = random.Next(50, 100); }
/// <summary> /// Removes the given delegate from the collision world. /// </summary> /// <param name="reference">Reference to the delegate contained by the collision world, returned by CollisionWorld::AddDelegate().</param> public void RemoveDelegate(CollisionDelegateReference reference) { m_Delegates[reference.m_NodeGroup].Remove(reference.m_Node); }
/// <summary> /// Adds the given delegate to the designated delegate group. /// </summary> /// <param name="group">Group the delegate should be added to.</param> /// <param name="collisionDelegate">Collision delegate to be added.</param> /// <returns>A CollisionDelegateReference to be used for removal of the delegate from the collision world and for manipulation of the delegate.</returns> public CollisionDelegateReference AddDelegate(CollisionGroupIdentifier group, CollisionDelegate collisionDelegate) { AutoCreateCollisionGroup(group); CollisionDelegateReference newReference = new CollisionDelegateReference(); newReference.m_NodeGroup = group; newReference.m_Node = m_Delegates[group].AddLast(collisionDelegate); newReference.m_OwnerWorld = this; return newReference; }