How do I create a new object if its name is not in the array

0 favourites
  • 5 posts
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Hi guys,

    I can't find a way to create an object (UI) when an enemy is spawned and is not already in the array.

    The sentence looks a bit crazy to understand so let me explain.

    For each enemy of the same instance that is spawned, I would like to have only 1 UI object that is displayed.

    Each time there is an enemy spawned, I populate the array with the name of the enemy.

    At the moment, each time that an enemy is spawned, I generate 1 UI object for it.

    I just want to have 1 UI object of this enemy because I want to have a number that corresponds to the sum of the same enemies on the UI object.

    I want to keep an array because I would like to sort the UI.

    Thanks for your help!

  • I think it would be much easier to create a UI element for each enemy type beforehand, all these UI elements would be invisible at first. Then you set the UI element visibility to "visible" each time an instance is spawned. When the last instance is destroyed, you simply set the ui element's visibility to "invisible".

    I hope I got it right, you're trying to make an enemy counter for each type of enemy.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi Zed2100,

    yes but my issue is that I have a lot of enemies and depending on the enemy spawned, I would like to display the UI close to the edge of the screen.

    Let's say that if enemy 03 is spawned first, I would like to have it close to the edge and not 3 spots away from the edge, leaving an empty spot between the UI of the enemy 03 and the ledge of the screen.

  • I would like to display the UI close to the edge of the screen.

    What do you mean by "UI" exactly, can you give an example ?

  • UI, I meant UI object which is the term we use in video game for user interface such as health gauge, radar, icons.

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