SpriteBaseTileTouchingIndex Method |
Namespace: (Default Namespace)Assembly: Default (in Default.exe) Version: 1.0.0.0
Syntax public virtual int TileTouchingIndex(
int TileValue,
bool InitialOnly,
bool MarkAsProcessed
)
Parameters
- TileValue
- Type: SystemInt32
Tile index to search for - InitialOnly
- Type: SystemBoolean
If this is true, the tile will only be considered if the sprite
just started touching it (was not touching it before). - MarkAsProcessed
- Type: SystemBoolean
If this is true, the tile that is returned is immediately
marked as processed, otherwise it is left as unprocessed and may still be affected by
other tile interaction functions.
Return Value
Type:
Int32The index of the next unprocessed tile in
TouchedTiles if one
exists with the specified
TileValue, or -1 if no such tile exists.
Remarks While
TileUseUp(Int32, Counter, Int32) and
TileTake(Int32, Counter, Int32) provide simple
access to common behaviors related to tile interactions, they aren't expected to cover
all behaviors you might want to implement related to tile interactions. This function
provides a piece of functionality that will be useful in more detailed control over
tile interactions.
Examples
The following example demonstrates how you could activate the next inactive instance of
a sprite in the "Points" category at the location of any tile whose tile number is 10
when the sprite touches the tile, only when the sprite first touches the tile. Performing
this in a while loop ensures that all such tiles that the sprite is initially touching get
processed at once, which is important because it won't be initially touching them any more
in the next frame. TempNum is any temporary numeric variable, such as a sprite parameter.
if (TouchTiles(TileCategoryName.Touchable))
{
TempNum = TileTouchingIndex(10, true, true);
while(TempNum > 0)
{
TileActivateSprite(TempNum, ParentLayer.m_SpriteCategories.Points, true);
TempNum = TileTouchingIndex(10, true, true);
}
}
See Also