position_change

Changes all instances at a given position to a different object.

Syntax:

position_change(x, y, obj, perf);


Argument Description
x The x coordinate of where to change colliding instances.
y The y coordinate of where to change colliding instances.
obj The new object the calling object will change into.
perf Whether to perform that new object's Create event (true) or not (false).


Returns: N/A


Description

This function will check a position for a collision with any instances at the given point, and if there is one, it will change all instances in collision to be instances of the chosen object. You can set the "perf" argument to true which will force GameMaker: Studio to perform the destroy event of the found instance and the create event of the new instance, or false to not perform either of these events. Please note, that if you choose not to perform the destroy and create events, any instance created that uses a variable normally defined in the create event will crash the game as that variable will no longer exist.


Example:

position_change(200, 200, obj_Bird, true);

This will change all instances colliding at point (200,200) into an instance of "obj_Bird", performing "obj_Bird"s Create event for each of them in the process.


Back: Collision Checking
Next: position_destroy
© Copyright YoYo Games Ltd. 2018 All Rights Reserved