How do I do this create enemy and variable style

Get help using Construct 2

Post » Fri Oct 30, 2015 10:23 pm

Ok so my idea and yes if you were following my other post i am still working on that same turn based.

ATM I am trying to figure out how to implement a monster attackQue system. Now keep in mind These monster are create not already there.

And the number of monster is going to be randomly created from 1-5.

How would i go about getting a brand new variable to each created. in other word If each monster is create then add one to a family of monster but i would like it to be like this for each sprite monster created have the variable to be in order of 1 2 3 4 5. So that when i do the monster Que each monster would have a turn. Because this is created and not already there how would i math out the variable so that it can be 1 2 3 4 5 on each new create sprite.

Again this is for the monster attack que. I already got a plan on how to get the event to run them its just because they are created how will i add in variable in that matter.
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Sat Oct 31, 2015 7:59 am

Make a global variable (example monsterNumber) and set its value to 1 before each spawning of monsters.
Give each monster an internal (instance) variable (example myNumber) and initialize it to 0 after every fight (and on start of game).

Now when spawning monsters assign the first one's myNumber the value of monsterNumber and then increment monsterNumber by 1. Repeat for number of monsters.

Now you just have to use your Family/monster myNumber compare to activate.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
69
S
18
G
8
Posts: 639
Reputation: 9,549

Post » Sun Nov 01, 2015 3:54 am

You are a genius. I would have never guess to use global variable like that Question can I use local variable as It will be use on one set of layout and not the others ?
B
52
S
24
G
6
Posts: 391
Reputation: 7,845

Post » Sun Nov 01, 2015 6:54 am

If you not using it globally then yes make a instance variable holder.. aka invisible sprite and use it to hold your monsterNumber local variable.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
69
S
18
G
8
Posts: 639
Reputation: 9,549


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 28 guests