Construct 2 Tutorials – Spawning Enemies



what's going on everybody Edie here bringing you another tutorial one thing that was asked was how do you create or spawn enemies off-screen in a game like contra so I'm going to show you how to do that my next video tutorial series that I'll probably be doing will be a contra type clone so this fits in nicely and I can show you how to do this real quick so I have my hero I have my enemy I have my layouts just real quick I'm going to show you so this dark outside box is my layout so all this in the square is my layout okay and then this dotted line here is my window so this is what the player sees and then as he runs it's going to scroll all right that's important because we're going to make these guys spawn off-screen but still in the layout okay so let's turn that back on and what we want we want him to have the bullet behavior okay and the destroy outside of layout behavior so that way when he gets to the NP doesn't just keep on running all right we're going to give them a bullet speed of 200 and set angle to no okay and then we're going to create this sprite that I called spawn point so what we're going to do is we're going to use this as our marker for when we should spawn the character okay so we're going to put one there we'll stick one over here maybe one right here and then any one more rights here okay now what we want to do is we want to see where this guy looks good spawning so I say right maybe right there so maybe 308 maybe 310 is a good spot for him to spawn or maybe 500 so 310 and 500 so let's write that down 310 and 500 for the y okay and our window size is 640 by 640 so we want them to spawn somewhere past the window okay so now I'm going to go ahead and set up our events so what we want to do is when our hero collides with our spawn point first thing we're going to do is we're going to destroy the spawn point all right and then we're going to create an object of our enemy on layer one now X is going to be so our our player is currently in the middle of the screen right because it's scroll to behavior our window width is 640 so he's at 320 so let's do player its hero x+ so another 320 would be right at the edge so let's say 360 all right and then Y we're going to use the choose expression we're going to choose between 310 and 500 remember we picked those numbers moving the guy around so it'll he'll either appear on the top platform or the bottom platform let me do that okay and then we're going to set our enemies animation to the run animation and we're going to set the enemies bullet angle of motion to 180 so he runs to the left okay so now we've run that boom boom boom and boom all right and then real quick we can go back here and we can set all of these guys to invisible so you no longer see them and there's a quick way to make enemies appear off-screen all right alright thanks for watching and don't forget to check out learn construct to.com for more videos thank you you

9 thoughts on “Construct 2 Tutorials – Spawning Enemies

  1. Is possible create objects in another layouts?
    I mean using the same event sheet?
    like a portal

    When the hero collides with the portal(sprite) -> system goes to the layout x and creates an enemy in the layout x.
    Or should I use an event sheet for every layout I create?

  2. At what time? To make a enemy come in at random points from the top you would use something like -20 for the y and then something random for the x. So if you screen width is 600, you could do Random(0,600) for the X. That would give you a random number between 0 and 600

  3. Can't see what you're putting in the X & Y choose (What is the equation?) I want to have a random object drop in from different points above but I can't see how you're adding it.

    Thanks

Leave a Reply

Your email address will not be published. Required fields are marked *