Range

The Range alteration triggers events based on one sprite's proximity to another.
IMPORTANT: The target sprite must be on screen before this alteration is created !

create routine as Start launch targetArrow launch arrow end create sprite from uparrow.png as targetArrow where x=200 y=200 center=103,27 angle=45 end create sprite from uparrow.png as arrow where x=50 y=10 center=103,27 angle=340 having alt=moveArrow alt=TrackRange end create vector as moveArrow where speed=120 end create range as TrackRange where target=targetArrow distance=200 enter=near exit=leave arc=90 end create routine as near update sprite targetArrow where alpha=0.5 end create routine as leave update sprite targetArrow where alpha=1.0 end

Parameters

arc={number}
You can set an arc "in front" of your sprite such that the target sprite must be within that arc for events to fire. Imagine a cone extending from the front of your sprite. The arc sets this cone. The front is considered to be the angle at which the sprite is pointing. For example, if your sprite is currently at 45 degrees and the arc=20, then the target must be between 35 and 55 degrees for your sprite in order to register a range event.
completion={routine}
specify a routine to run when the target sprite enters range. If this is set then this alteration will close upon completion. This means that no exit event will fire and no more enter events will fire if the target sprite leaves then re-enters the range.
distance={number}
the number of pixels distance from the center points of the sprites to be considered in range.
enter={routine}
specify a routine to run when the target sprite enters range. This can fire multiple times if no completion event is set
exit={routine}
specify a routine to run when the target sprite leaves range. This can fire multiple times if no completion event is set
target={sprite}
the name of the sprite to watch