Game Development Reference
In-Depth Information
Figure 12-6. The Path Properties form showing path_distract
Implementing the Distract Behavior for the Parrot Object
1.
Create a new object called obj_path_offset in the Misc group. Add a Create event and
include an Execute Code action containing the following lines. This sets the object to
follow the distract path at a speed of 5 pixels per step, looping back to the beginning
when it reaches the end and using relative coordinates.
1: {
2: path_start( path_distract, 5, 1, false );
3: }
Return to obj_parrot and open its Create event. Add this additional line that creates an
instance of obj_path_offset at X = 0 , Y = 0 when the parrot is created. The
obj_path_offset object has no sprite so no one will ever see it.
instance_create( 0, 0, obj_path_offset );
2.
Still in the parrot object, add a Collision event with obj_enemy and include an Execute
Code action containing the following code:
1: {
2: if( other.id == target_id && state != ASTATE_DISTRACT )
3: {
4: state = ASTATE_DISTRACT;
5: alarm[0] = 300;
6: }
7: }
3.
 
Search WWH ::




Custom Search