PlanBaseWasSpriteTouching Method |
Determines if the specified sprite was touching this plan's rectangle in the previous frame.
Namespace: (Default Namespace)Assembly: Default (in Default.exe) Version: 1.0.0.0
Syntax public virtual bool WasSpriteTouching(
SpriteBase sprite
)
Parameters
- sprite
- Type: (Default Namespace)SpriteBase
Sprite to test
Return Value
Type:
BooleanTrue if the specified sprite was touching this plan's rectangle previously, or false
if it wasn't.
Remarks This function is identical to
IsSpriteTouching(SpriteBase) except that it operates
on the sprite's previous position instead of its current position. This is useful for
determining if the sprite just started touching a plan's rectangle or was already touching
it. Often times it's desirable to perform an automated action like a message only
when a sprite initially touches a plan's rectangle. It's not as desirable for plan rules
that also require other conditions to activate.
Consider, for example, a plan that displays
a message when the sprite touches it. This plan can automatically display the message only
when the sprite first touches the plan, and everything will be fine. But what happens if
it's also required that a button be pressed to activate the rule? The player may start
touching the plan without touching the button. Then when the player presses the button,
the rule won't activate because this is no longer the frame when the sprite initially
started touching the plan, so the plan may never get activated.
See Also