Create Objects of array value 0 then put array values in var

Get help using Construct 2

Post » Wed Sep 02, 2015 12:27 am

I read a lot about arrays, but i still cant understand some things, i just want to create 10 enemies (same sprite) with different values (from array) each minute but only those with value 0 in the array, and when my enemy its created then set values from array (of 0 enemies) to variables, i tried this but i cant understand why didn't works, if i have 50 items (with value 0) in the array then each minute i will spawn 10 sprites (each one of the value 0) and each sprite will have the values of Y, after each sprite is destroyed then the value of the array will be 1 then the enemy didn't spawn anymore, please help, i am still reading but arrays are so hard.

Image

I want to spawn 1 orange, 1 banana, 1 tomato and 1 carrot because they have the 0 value in the array, after i destroy each one then no enemies left to spawn, imagine if i have a big list of 50 items in the array with the 0 value, well i want to spawn 10 each minute.

Image

This events are an example but i tried a lot of different things, i tried this time using a capx example but this example dont use strings, i cant find any tutorial or example with strings, i tried to replicate all the events and i get this error:

Image

String its a text value, i cant find in the forum how to use strings with array.at :/

:( , i spend the whole day reading about arrays, searching in forums and reading tutorials, i just give up, if this is hard i cant imagine how real programming will be.

My Capx:

http://www.filedropper.com/arraynightmare
B
9
S
3
Posts: 142
Reputation: 1,108

Post » Wed Sep 02, 2015 8:50 am

You probably want to use int(x) expression. It converts strings to integer (value/number)
Take a look here https://www.scirra.com/manual/126/system-expressions at chapter "Values" for more information.
It's time for me to return the favor :)
B
32
S
9
G
9
Posts: 132
Reputation: 5,370

Post » Wed Sep 02, 2015 1:33 pm

SCIRRA wrote:No Programming Required!
You can now make advanced games without writing a line of code. Construct 2 does the hard work so you don't have to.


:)

ArraySpawners.capx
Image
B
65
S
23
G
7
Posts: 1,505
Reputation: 10,896

Post » Wed Sep 02, 2015 4:54 pm

When you load the array from json, it assumes all information to be in string format. Convert to integer or float with the expression delivered by the previous posters.

And don't forget to use curindex in the loop instead of 0 for the x index, when you set the values.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Thu Sep 03, 2015 12:05 am

korbaach wrote:
SCIRRA wrote:No Programming Required!
You can now make advanced games without writing a line of code. Construct 2 does the hard work so you don't have to.


:)

ArraySpawners.capx


Thank you so much for your help! you saved me again!! i will read about loops!
B
9
S
3
Posts: 142
Reputation: 1,108


Return to How do I....?

Who is online

Users browsing this forum: marcinkowski, unicornspitfire and 57 guests