Fangames > Programming Questions
Affecting Existing Objects
YoSniper:
--- Quote from: Kyir on June 15, 2015, 10:47:34 PM ---Would that make both objects react that way, or just Object B?
--- End quote ---
It would not affect objectA, unless you put code outside the "with" block. However, if there are multiple instances of objectB, all of them will be affected simultaneously.
pieceofcheese87:
Yeah, if they are 2 different objects then you can control all of one type by doing what yosniper said. You can also control one instance of an object with the instance_place function.
for example:
--- Code: ---a=instance_place(x,y+32,objectA);
with(a){ hspeed=10 }
--- End code ---
This will check for a collision with an object at 32 pixels under its origin. If it does find a collision, then the variable "a" will be replaced by that instance that it collides with.
Then, only that one instance of objectA will move to the right.
Another way to control 1 instance of an object is in a collision event, where you can use other, which means the instance it collides with.
Kyir:
Oh, yeah, I would have never thought of something like that. Thank you very much!
Navigation
[0] Message Index
[*] Previous page
Go to full version