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

Get help using Construct 2

Post » Sun Sep 21, 2014 3:37 am

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!
You do not have the required permissions to view the files attached to this post.
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Sun Sep 21, 2014 1:55 pm

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.
ImageImage
B
44
S
14
G
10
Posts: 167
Reputation: 7,781

Post » Sun Sep 21, 2014 5:42 pm

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.
B
26
S
10
G
3
Posts: 72
Reputation: 4,008

Post » Mon Sep 22, 2014 10:02 am

Underdog wrote: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 ?
ImageImage
B
44
S
14
G
10
Posts: 167
Reputation: 7,781

Post » Mon Sep 22, 2014 11:42 am

UI, I meant UI object which is the term we use in video game for user interface such as health gauge, radar, icons.
B
26
S
10
G
3
Posts: 72
Reputation: 4,008


Return to How do I....?

Who is online

Users browsing this forum: R0J0hound and 6 guests