How do I create array depended objects

0 favourites
  • 6 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hello

    How can i create or assign existing objects accordingly to array.

    For example i have an array which has 3 cells called red and 3 cells called green and accordingly i want to create 3 red sprites and 3 green sprites or assign existing red and green sprites.

    How can I do it?

  • please clarify what you are trying to do.

    seems like you need to do a For Each on the objects, if they don't exist then Create sprite.

    what are you assigning to the sprites?

    when you say you have an array that has 3 cells called 'red'.. I don't understand.

    do you have an array like this?

    X(0) = "red"

    X(1) = "red"

    X(2) = "red"

    X(3) = "green"

    X(4) = "green"

    X(5) = "green"

    or is your array like this?

    X(0) (0) = "red"

    X(0) (1) = "green"

    X(1) (0) = "red"

    X(1) (1) = "green"

    X(2) (0) = "red"

    X(2) (1) = "green"

  • Hej jobel doesn't matter what array do a have

    the question is how can I assign cells in array to create objects?

  • well it matters what information is in your array.

    how can I assign cells in array

    assign cells? do you mean, add to the array?

    use Push or Insert

    and I would highly recommend doing this tutorial ... -beginners

  • I know these tutorials and i know how to create cells. My question is how to create objects based on array.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • When creating an object, you can set its UID as value of a cell.

    This way, if you know what your cell is supposed to be (for example X2 is supposed to be red) the UID contained at will be of a red sprite.

    (in the event where you Create object Sprite, you set Array X 2 to Sprite.UID)

    Your sprite can be red by either being an instance of a Sprite that only contain an animation frame Red, or the instance of a Sprite that is set to animation frame Red and whose animation is 0.

    Depending on what you are attempting to do with your Sprite later on, one or the other solution may be more appropriate.

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