How do I get array to display?

Not favoritedFavorited Favorited 1 favourites
  • 6 posts
From the Asset Store
Make a displayed number gradually increase or decrease, making an impression of a real-time counting.
  • Hi guys,

    I'm after a bit of help when using array data.

    I have a grid 5 x 10 made of sprites size 64x64 on layout and an array the same size which hold info on what objects to display in grid.

    How can I say get array data x and y to corresponde to the grid at the same position?

    I'll be changing the array data in realtime so need the grid on screen to update as well.

    Many thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can add instance variables to the sprite — indexX and indexY — and fill them with values: indexX from 0 to 4, and indexY from 0 to 9.

    Then you’ll be able to pick the sprite instance corresponding to any array element.

    Another option is to pick the sprites based on their position. Assuming your first sprite's position is (0,0), you can do this:

    + Array: For each XY element
    + Array: Current value = 1
    ----+ Sprite: X = Array.CurX×64
    ----+ Sprite: Y = Array.CurY×64
    -----> Sprite: Set visibility Visible
    
  • Thanks for the help,

    I'll try the instance variable idea I have really explored them before.

  • Thanks for the help,

    I'll try the instance variable idea I have really explored them before.

    My grid starts at about 832 X and 64 y otherwise it would have been easy to align the array and grid position!

  • Ok, so modify the code a little:

    + Array: For each XY element
    + Array: Current value = 1
    ----+ Sprite: X = Array.CurX×64+832
    ----+ Sprite: Y = Array.CurY×64+64
    -----> Sprite: Set visibility Visible
    
  • You're an absolute ⭐

    Thanks.

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