How do I this spawns?

0 favourites
  • 3 posts
From the Asset Store
14 amazing sound files of game events like Level Ups, Level Completes, object spawn, object taking etc.
  • Hello friends, I need your help. I wanted to ask you how I can make some of the objects below (trees-apple-bush) appear inside the green island, try placing random(LayoutWidth) and random(LayoutHeight ) but they appear over the sea...that is, the light blue area and they don't stop appearing...I would like 1 to appear and when I delete it, another is created in a random area...

    From already thank you very much...

    Credits corresponding to the creators of the sprites and tilemaps

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I gave you a video link on your Reddit post that goes into more detail if you need it.

    Let's assume your green island is a Sprite with the origin at its center with the name Island.

    It's a square so you can grab the area with a formula

    Create Object at:

    X position: Island.X-(Island.width/2)+random(Island.width)

    Y position: Island.Y-(Island.Height/2)+random(Island.Height)

    I suggest putting that in a function - then whenever you destroy an object you call an object.

    I made a quick example program of it - Sprite = island and sprite2 = object you create.

    The algorithm does not take into account your objects width and height, so they will hang off the ledge if you end up randomly hitting very near the edges.

  • Thank you very much friend, it was just what I was looking for :)

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