• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Tile Delete at Position

Right now I am in the middle of converting all legacy codes from the 8.1 build of my game to GMS:2. Thus far I've succeeded in a few tile-based scripts. But one thing that still eludes me is how specific tiles can be deleted for the sake of preserving memory.

Before, my code looked like this:
Code:
tile_layer_delete_at(1000, tileUnitWidth * i, room_height * (1.5) + tileUnitHeight);
One thing I am confused about is what the correct syntax is to accomplish just this. So far I see layer_tile_destroy but the issue is I do not know what it means when it needs a tile_element_id or if this would even work.

My tile generator creates the background tiles procedurally, scrolls downward, and deletes as soon as it goes offscreen along the y-axis. I'm trying to do the same thing with GMS:2 but I'm at a roadblock.

I am hoping someone more experienced can point me in the right direction. Any pertinent response would be greatly appreciated as always! ^_^
 

jo-thijs

Member
Right now I am in the middle of converting all legacy codes from the 8.1 build of my game to GMS:2. Thus far I've succeeded in a few tile-based scripts. But one thing that still eludes me is how specific tiles can be deleted for the sake of preserving memory.

Before, my code looked like this:
Code:
tile_layer_delete_at(1000, tileUnitWidth * i, room_height * (1.5) + tileUnitHeight);
One thing I am confused about is what the correct syntax is to accomplish just this. So far I see layer_tile_destroy but the issue is I do not know what it means when it needs a tile_element_id or if this would even work.

My tile generator creates the background tiles procedurally, scrolls downward, and deletes as soon as it goes offscreen along the y-axis. I'm trying to do the same thing with GMS:2 but I'm at a roadblock.

I am hoping someone more experienced can point me in the right direction. Any pertinent response would be greatly appreciated as always! ^_^
Tiles in GM8.1 are different from tiles in GM:S 2.
In GM8.1 tiles were not truely tiles (as tiles could have arbitrary positions and shapes).
In GM:S 2.0 tiles are actual tiles, they are rectangles in a grid.
Deleting a tile in GM:S 2 to free up space doesn't make sense, as the used memory depends only on the grid size of the tile layer.

GM:S 2 does have something called "asset / sprite layers", which do work similarly to GM8.1 tiles.
Have a look at:
https://docs2.yoyogames.com/source/_build/3_scripting/4_gml_reference/rooms/layers/index.html
https://docs2.yoyogames.com/source/_build/3_scripting/4_gml_reference/rooms/sprites/index.html
to get an idea of the operations you can apply to these layers.

In all likelyhood, you will need to redesign your system more thoroughly than creating legacy scripts.
The odds are you can benefit from GM:S 2's true tile system.
 
Top