Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Remove tile from tilemap
#1
Hi! I am trying to remove tile from tilemap (for ring collision) with this code:
Code:
if(ring_found)
{
    PlaySoundId(7);
    TLN_SetTilemapTile(foreground_tilemap,tileinfo.row,tileinfo.col,TLN_Tile(0));
    TLN_SetLayer(LAYER_FOREGROUND,NULL,foreground_tilemap);
    rings++;
}
But it gives Invalid Pallete reference when running SetLayer(). Any solution?
Reply
#2
Are you using the same assets you posted some days ago?

It's not needed to reconfigure layer with TLN_SetLayer() once you modify the tilemap with TLN_SetTilemapTile(), they're already linked.
Reply
#3
Removed SetLayer(), still not removing tile. But no more errors in log.
Reply
#4
Are you passing the correct row and column? The following code works for me, when I press input 1, it removes the first ring:

Code:
    while (TLN_ProcessWindow()) {
        if (TLN_GetInput(INPUT_BUTTON1)) {
            Tile tile = {0};
            TLN_SetTilemapTile(foreground_tilemap, 54, 6, &tile);
        }
        TLN_DrawFrame(0);
    }


Attached Files Thumbnail(s)
   
Reply
#5
Thanks! You need to define empty tile before setting it and use
Code:
Tile tile={0};
TLN_SetTilemapTile(foreground_tilemap,tileinfo.row,tileinfo.col,&tile);
instead of
Code:
TLN_SetTilemapTile(foreground_tilemap,tileinfo.row,tileinfo.col,NULL);
Reply
#6
Thumbs Up 
Welcome!

I understand the confusion, it seems more intuitive to delete a tile passing just NULL instead of a valid pointer with index 0, right? I'll add this behavior in next update
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)