How do I add ennemy sprites in my level?

  • Hello to all

    In my game i need now to add ennemies.

    My Layout game is 15000 width, 1080height (window is 1920x1080)

    how to add (spawn) ennemies at random positions with a random time and outside the screen (entering when player move)?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Random time is relatively easy. Just use the every x seconds and use random(#,#) in your spawner.

    You can either use x value; player.x > 1200 activate spawner 1 or you can use an industry standard... triggers; invisible sprites along the path and turn on off screen spawners (both ahead and behind player) when player overlaps them.

    As for spawning mobs off screen simple make their x value greater or less than screen width on creation.

  • Do you have any clear capx?

  • i have the pink spawners objects on the left and right side, who are allways at the same position no parallax for that layer.

    http://s21.postimg.org/epmgd8j9h/ennemy_spawn.jpg

    i tried this event but sprites are not spawned from the point "0" of the pink spawners

    when im moving on the level who scroll the sprites are not created at the right places ( spawners left & right)

    whats wrong on my code events?

  • Classic off-by-one. If you have ImagePoints 0,1,2, ImagePointCount will be 3. Subtract one from ImagePointCount to get the last ImagePoint.

  • what???

    what i have to clearly add in the events??

  • what code event i have to add?

  • here is how i did it:

    Every 3 seconds > Create Object (Enemy) on layer 1 at (Layout width + Total Distance + 40 + Random(70) , 0)

    in my situation Total Distance is a global number. but u can just make it "Layout Width + something"

    Let me know if it helped. I got a question too, if u can help me let me know

  • Hello, what kind of help you need

  • im stuck.. .. whats the "exact" formula to add. :s

    this is my actual code event.

  • The Illuminati is the Enemy (Don't Ask) The Player is, Surprisingly, the Player, and The IllumSpawn is the Enemy Spawner. Put your enemy off the layout and put that it will be destroyed on the start of the layout so the player won't be annoyed with an extra enemy. Also, set that They will spawn on your Game Layer and The Image Point depends, All Sprites come with an Image Point 0, called the Origin, which is the center, but you can set your own. If you have, It will tell you what value it is. (Ignore the fact that I put 2, That is because I'm using 2 Spawners that are not the same). You then type in that every *blank* seconds, it will spawn (The seconds really doesn't matter, you can do 1, 5, or 100 seconds. I did that it will pick randomly between 1 and 3 seconds) Then, it should spawn pretty Fine. If you have any Issues, just ask me.

  • the problem is, if the player is walking (scrolling platform game) the imagepoint doesn't stay at the right place i use the imagepoint of the spawner object who are outside the window

  • ImagePoint should just be 0.

  • i tried also but nothing change, sprites are not spawned from spawners objects point 0, when the player is moving

  • ImagePoint should just be 0.

    The Image Point doesn't have to be 0 if you went in and added more imagepoints. If you haven't, it should be 0.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)