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

0 favourites
  • 5 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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.

    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.

    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:

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

    <img src="{SMILIES_PATH}/icon_e_sad.gif" alt=":(" title="Sad"> , 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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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

  • 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.

  • > 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!

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