|
This is a very usefull function.
The main useage of this function is to delete objects automatically after
a 2D animation on a specific polygon has ended (explosion effect animation for example)
Example:
After shooting down a helicoter we would like to have an explosion
to do that we do the following:
1) Using WorldBuilder\Webmaker we create an object that contains usually one polygon with explosion\fire animation
2) At the beginning of the program we disable this object so it is not seen
3) When we need to create an explosion we do the following:
- We duplicate the explosion effect object (using STATE_object_duplicate() )
- We move the new copy to the location where we need the effect ( STATE_object_get_location() and STATE_object_set_location() ) make sure that the copy is enabled
- And here comes our function. We set an event using STATE_object_set_event_on_animation_frame()
to delete the object automatically once the animation is over.
This function is similar to STATE_object_set_event() only that the event is triggered
by an animation frame and not by time.
When the animation on the given polygon will finish showing the given frame.
The event will take place.
Note that the given polygon must belong to the given object
There only two events that could be used.
STATE_DELETE and STATE_DISABLE.
Example for usage: Lets say we have an explosion and now we have created
an object for showing the smoke, the smoke will be an animation on a polygon.
the animation will show smoke evaporating. using this function we can automatically delete
the object once the animation is finished
If animation_frame==-1 it has a special meaning, it means expire after the last frame.
Note that after doing delete you cant use the handle any more
so good practice is to do the following:
STATE_object_set_event_on_animation_frame(obj_handle, polygon_handle, animation_frame, STATE_DELETE);
obj_handle=NULL;
Arguments:
object_handle: The object that should be associated with the event.
polygon_handle: A polygon of the object that has an animation
animation_frame: The animation frame number that should trigger the event.
event: STATE_DELETE or STATE_DISABLE. See remarks.
|