First of make a object called obj_controller(Note that this does not require a sprite)
Also create another object named obj_enemy(Give this a sprite)
Now open up obj_controller and add the following code
global.enemy_amount=0;//Sets a variable to 0 on the creation of the object
Then in the step event of the same object add the following.
if (global.enemy_amount<10){//Checks to se if there is more then 10 objects
instance_create(random(room_width),0,obj_enemy);//Create the enemy on a random x position
global.enemy_amount+=1;
}
Now close and save this object and open up obj_enemy and in the create event add
motion_set(-90,random(12))//Gives the object a random speed in a downwards direction
Now in the destroy event add the following
global.enemy_amount-=1;//The instance is destroyed so take away from the amount
Now in the outside room event add
instance_destroy()
This should work fine.
Please give credit.
I will try and help with any problems
.
Users logged in:
Comments
Loading comments...