Hey, all. I'm trying to learn bitmasking with tile layers. It's taken me awhile to grasp it, but at this point, it seems pretty straightforward. I followed an old post from 2016 to start setting things up, but I'm having an issue. When I go back and check the tile index after setting a bit, the index comes back NOT ignoring the bit I set. Let's say index is 1, then I set a bit, and suddenly the index is 33. The post from 2016 mentioned a bug but Mike Daily said it was fixed internally and that was over 3 years ago. Is it still broken?
Single object in a room with tiles, from a 4x4 tile set, so possibility of indices 0 - 15.
Thanks for any help!
Create Event
Step Event
Single object in a room with tiles, from a 4x4 tile set, so possibility of indices 0 - 15.
Thanks for any help!
Create Event
Code:
// get the tilemap
tmap=layer_tilemap_get_id("TL_Test");
// set the mask
var _mask = tile_rotate | tile_mirror | tile_flip | 15;
//tilemap_set_mask(tmap, _mask);
tilemap_set_global_mask(_mask);
Step Event
Code:
/// @desc Set bit / get index
var _tdata,_tdatanew,_tindex;
#region left click to see tile index
if(mouse_check_button_pressed(mb_left)){
// get data from clicked tile
_tdata=tilemap_get_at_pixel(tmap,mouse_x,mouse_y);
// exit on void tile
if(_tdata==0){
show_message("Empty space!");
exit;
}
// get index in case a property has been changed
_tindex=tile_get_index(_tdata);
// Show the index
show_message("Tile index: "+string(_tindex));
}#endregion
#region right click to set bit 6
if(mouse_check_button_pressed(mb_right)){
// get data from clicked tile
_tdata=tilemap_get_at_pixel(tmap,mouse_x,mouse_y);
// exit on void tile
if(_tdata==0){
show_message("Empty space!");
exit;
}
// set the sixth bit
_tdatanew = _tdata | 32;
// show tile data
show_message("Tile data blob was: "+string(_tdata)
+", and is now: "+string(_tdatanew));
// place the modified tile
tilemap_set_at_pixel(tmap,_tdatanew,mouse_x,mouse_y);
}#endregion