evildead9000
Member
Here's one that's probably been asked a million times and I apologize for probably posting it again, but for some reason controlling multiple instances of the same object eludes me greatly!
I'm creating a simple shooter like Galaga / Space Invaders, and have multiple instances of an enemy. In the step event of that enemy I have the following script.
Can someone please explain the difference between
In the create event the global.Enemy_State is "Appearing". In the appearing script I have a switch because numerous enemies will also use it:
I've also attempted the code above without "with (obj_Enemy_1)". What happens is that ALL instances of Enemy_1 stop wherever the first one did.
I would like each Enemy_1 to stop at "room_height / random_range(2,5)", then attack.
Can someone please explain the difference between using "with (obj_Enemy_1)" and not?
I'm creating a simple shooter like Galaga / Space Invaders, and have multiple instances of an enemy. In the step event of that enemy I have the following script.
Code:
switch (global.Enemy_State)
{
case "Appearing": scr_Enemy_Appearing(); break;
case "Attacking": scr_Enemy_Attacking(); break;
}
script_execute(global.Enemy_State);
In the create event the global.Enemy_State is "Appearing". In the appearing script I have a switch because numerous enemies will also use it:
Code:
case obj_Enemy_1:
with (obj_Enemy_1) {
mp_potential_step(obj_Player1.x, obj_Player1.y, 2, true);
if y >= room_height / random_range(2,5){
global.Enemy_1_State = "Attacking";
}
}
break;
}
I would like each Enemy_1 to stop at "room_height / random_range(2,5)", then attack.
Can someone please explain the difference between using "with (obj_Enemy_1)" and not?
Last edited: