Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by michalbe

Is it somehow possible to change the tile on the level's layer during the game in some easy way? I only want to change the image in the background and it's probably problematic issue now (or I just didn't find anything in docs).

1 decade ago by dominic

In any ig.Map (Background or Collision), you can directly access the .data array and manipulate it. Note that the tiles are stored as .data[row][collumn]. You can also use the #.getTile() and .setTile() methods, if you want to work with pixel coordinates.

For BackgroundMaps changes will be visible immiediately, as long as you don't use the pre-render mode.

Example, in your Game class:
// Change row 5, collumn 3 (counting starts at 0) for the first bg map to tile 7
this.backgroundMaps[0].data[5][3] = 7;

1 decade ago by michalbe

Great, but can I somehow change the tiles remembered? If I want to edit them during the game (eg. using canvas API I want to change color or draw something on them) to use them in example you provided? Thanks!

1 decade ago by michalbe

Ok, just in case anyone will have similar issue in the future, the image/canvas of the given layer is stored in:

this.backgroundMaps[layerNumber].tiles.data

Thanks!

1 decade ago by michalbe

Oh, but this is just a tileset. Is rendered level (tiles in a given order) stored somewhere?

1 decade ago by svenanders

yeah, ig.game.backgroundMaps[layerNumber].data
Page 1 of 1
« first « previous next › last »