O
Oz Locke
Guest
The issue was being caused by a part of the code that protected the player from new asteroids being spawned on top of them. There were a few fixes, including disabling that feature (not desirable!), disabling destruction of asteroids while invincible, or stopping the child asteroids from inheriting that particular code (as it's not really relevant for the children anyway)
------------------------------------------------------------------------------------------------------------------------------
I've been following the excellent intro videos from @ShaunJS and I've encountered an odd issue when trying to be a smart-ass on the destroy event for an object.
The object spawns two children when destroyed. For simplicity the course simply duplicates the spawn call:
Which works fine...
But I've been going over my code and converting to DRY and Object Oriented code where I can, for my own learning, so I tried replacing this with a for loop:
The code works, in that it spawns two children, but it doesn't spawn them in the correct location.
It spawns them together, but they spawn at a random location in the room.
I can't see anything wrong with my loop, am I misunderstanding how the destroy event works? Do the position co-ordinates of the object get lost before the loop can run?
------------------------------------------------------------------------------------------------------------------------------
I've been following the excellent intro videos from @ShaunJS and I've encountered an odd issue when trying to be a smart-ass on the destroy event for an object.
The object spawns two children when destroyed. For simplicity the course simply duplicates the spawn call:
Code:
instance_create(x, y, obj_asteroid_s);
instance_create(x, y, obj_asteroid_s);
But I've been going over my code and converting to DRY and Object Oriented code where I can, for my own learning, so I tried replacing this with a for loop:
Code:
for(i = 0; i < 2; i++){
instance_create(x, y, obj_asteroid_s);
};
It spawns them together, but they spawn at a random location in the room.
I can't see anything wrong with my loop, am I misunderstanding how the destroy event works? Do the position co-ordinates of the object get lost before the loop can run?
Last edited by a moderator: