Is there any way to spawn a random amount of sprites?

0 favourites
  • 12 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template for top-down view games)
  • I have this sprite which works as a base center, so I'm trying to on start of layout, create a random cuantity from x to y sprites on that base but I see no way to do it.

  • Yes its possible.

    Can you explain better how it should work?

    You have a sprite already on your layout that is your base starting point and you want to create like 100 new sprites from this base sprite to position x,y ?

  • Yeah sure, so this base center has 4 image points, and when the layout has begun, I wanna create enemies from that base, but I want that number of enemies to be random, and to spawn randomly from those 4 image points.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For example, in one game, you could face 5 enemies, in other, you could be fighting 7, or 3....

  • Ok, but you only have 4 image points (spawning points), where should the others be placed?

  • in one of the four image points, 2,3 or every sprite could spawn in one single image point, it's random. But that is not the point, the thing is making them spawn in a random quantity.

  • in one of the four image points, 2,3 or every sprite could spawn in one single image point, it's random. But that is not the point, the thing is making them spawn in a random quantity.

    Use a for.

    Im using 2 variables to be easier to understand, but its not necessary.

    Var min_enemies=1

    Var max_enemies=7

    For 1 to int(random(min_enemies,max_enemies+1))

    Create sprite enemy at X,Y

  • those variables are instance of global?

  • Tried using the for but it's creating a large amount of sprites and fps go really low hahaha

  • those variables are instance of global?

    Yes.

  • mmmm It is exactly what I did, but The thing is behaving weird and it keeps spawning a non wanting and large amount of sprites, my cpu starts burning when I run it (my pc is good) hahaha

    Edit: Ok so now, for some reason it works lmao.

    One more question if I'm not bothering (i'm already very grateful for your help), is it posible to select a random layer? I wanna make an event were if you step on something, 1 of 3 minigames run, each minigame on a different layer.

  • choose("layername","layername2","layername3")

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