Game Development Reference
In-Depth Information
9. Include a Start Block action.
10. Include an Execute Script action for the Script check_object_returned with
Argument0 set to obj_lift_left , Argument1 set to horizontal_offset , Argument2 set
to 0 , and Argument3 set to true . The arguments for this script take the same form as
the original Check Object action with the Object to check for first, followed by X and Y
coordinates, and then an option to treat the co-ordinates as Relative . Therefore,
initially this action checks for instances of obj_lift_left 16 pixels to the right of the
current object. Significantly, though, this script creates a variable called returned that
either contains the instance found or a negative value if no instance is found.
11. Include a Test Variable action that tests if returned is larger than 0 . If the value is
negative, then there are no more instances and we have reached the end of the line.
12. Include a Start Block action.
13. Follow this with another Execute Script action for the Script change_instance_for with
Argument0 set to returned , Argument1 set to obj_lift_right , and Argument2 set to
true . The first argument is the instance to be changed. In the original Change Instance
action, this could only be the current object, but our new script can be called on any
instance. The remaining arguments take the same form as the original action with the
object to Change into coming next, followed by an option for Perform Events .
Therefore, this action changes the instance returned previously into an instance of
obj_lift_right and performs Destroy and Create events.
14. Include a Set Variable action ( control tab) that sets horizontal_offset Relative to 16 .
This moves the position we are checking 16 pixels along the line.
15. Include an End Block action.
16. Include a second End Block action.
17. Include a Change Instance action ( main1 tab) that changes into obj_lift_right with
Perform events . There should now be 11 actions in the Collision event for obj_solid ,
as shown in Figure 6-5.
Figure 6-5. The Collision event with obj_solid for obj_lift_left
 
Search WWH ::




Custom Search