How to use an array to store per-tile data with a tilemap?

0 favourites
From the Asset Store
Data+ is the best Data Management solution for Construct 3. It contains 4 Addons (Plugin & Behavior).
  • I can<t do all tiles manually, I would need to do something like this: Everywhere where there's a white tile, set the value of the array to 1. (at the same coodinate in the array for each)

    Is there a way to simply do: whatever the position if tile white set value of the array to 1 at the same position in the array?

    I tried to loop each tile to check if they are white but this just takes too much power, so I have to use specific coordinate like (mouse.x;mous.y) and convert it to tileposition which I won't be able to rely on later in my project.

  • You could have a value in the array which specifies which region a tile belongs to, then check tiles per region only when you need to.

    You would have to set this value before the game begins manually though.

    Also be aware that when it comes to foreach loops doing

    array = 1,

    foreach

    is more efficient than doing,

    foreach,

    array = 1

  • It would probably be easier to make a small level editor project. You can use your 40K sprites in it to build a map (because the performance doesn't matter). Use "For each TileSprite" to automatically convert them to a tilemap, and copy their values to an array.

    Then export Tilemap.TilesJSON and Array.AsJSON in the editor, and import these strings to your main game. Then all you'll have to do is load them into the tilemap and array.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I got this to work:

    It just change the tiles colour if the value of the array=0 at same tile position in the array using positiontotileX(mouse.x)&positiontotiley(mouse.y) And its bugged when condition on "every tick" it just colours a big square in the tilemap.

    But now I would need to do the contrary, set an array value when tile=0 (colour)

    And do I have to always rely on a specific position in this case (mouse.x,y) to change an array value? I would like to do like:at (tile.x,y) which i can’t figure out how.

    Also any tutorials online on how to use tilemaps with arrays? please

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