Spawning group of objects

0 favourites
  • 11 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • Hello, Im working on an infinite running game and I need to solve this in the best way posible.

    Currently Im spawning objects individually at a determined position, for example:

    I spawn the ground

    Then I spawn a wall in the middle

    Then I spawn an item after the wall

    Then I spawn an enemy after the item

    I can continue like this but its not practival, besides sometimes I will have two enemies or no wall.

    I would like to have this setup of items like a template, then just spawn the hole template, this way I can have many template or setups and continue spawning them endlessly until the player dies.

    Is there a good way to do this??

    Thank you

  • It sounds like functions are the right way to go. Create a function for each template, and call one whenever it's needed. For example, create 3 functions, each with a different template, and name them:

    Template1

    Template2

    Template3

    Whenever the played reaches the point that new level elements need to be drawn, use the action:

    call function("Template"&Choose(1,2,3))

    This will call one of the 3 templates at random. You could also do something more dynamic, and add little variation to each template so the player doesn't recognize the pattern. You could go even more dynamic by using a single function, spawn all the objects, and randomly set their properties from a set of values. Of course, this may not be practical depending on your game play. Regardless, I think functions are what you're looking for.

  • Thank you, I will try it.

  • Sounds more like you want Containers, I recently started using them and they are great for Create/Destroy. I created a toolbar of objects, put them all in a container, then added a button to create the toolbar on demand and BOOM they all come in. I did notice that you still have to place the objects related tot eh toolbar on ImagePoints and Pin them if you want to move the toolbar around but that is all achievable easily.

    scirra.com/manual/150/containers

  • jbmoyer

    Since containers would spawn all the objects as the same spot, he'd still need to have actions to set their properties. It would save a few lines of code if the exact same set of objects spawned for every template. Containers wouldn't be practical if more than one of any object needed to be spawned. I still believe functions are what he's looking for.

  • Functions work like a charm! besides it helps me get my sheets more organized.

    Just read the manual about functions and 2 minutes later I had a Spawning function, it was so easy.

    Thank you.

  • yeah no sweat, whatever works, sounds like both could work in this instance, Functions do give you more granular control. Glad you got it working!

  • You know, the more I think about it, I don't think Containers will help unless we can create instances of them. I haven't looked into that yet, but if we cant, Functions are your only. Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey zatyka, I'm having the same issue you had. You can share your .capx or post an screenshot of it? I'm trying to create the same solution with Functions but until now I couldn't ;(

  • Hi almeidamarcell

    Did you mean to direct your request to hazneliel? I'm not sure what issue you're referring to. I never made a capx for this topics.

  • Hi. I want to add different templates for spawned enemies to have different shapes like V or a straight line or a circle in a sidescrolling game.

    I found a template that uses invisible spawn points for random enemy spawning but nothing for shapes yet.

    So the basic idea is to add spawnpoint_circle in a circle shape and then spawn enemies for all points and then add spawnpoint_line to the layout and select randomly between the different kinds of spawnpoints to start spawning your enemies in a shape. Or is there another/better way to do this?

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