Posts: 195
Threads: 25
Joined: Dec 2020
Reputation:
1
Hi! I maybe found a bug with layers.
If I have a raster callback interacting with a layer, but I disable this layer somewhere else in the code, the layer is still enabled. Is this behavior normal? Wouldn't it cause problems if I want to keep it disabled for some reasons?
Thanks for your answer!
Posts: 680
Threads: 33
Joined: Jan 1970
Reputation:
13
Hi,
I can't reproduce what you describe. You can disable or enable layers inside raster callbacks, and they keep in that state until you change it. Take into account that setting the type of layer (i.e. tilemaps, bitmap, objects...) automatically enables it.
This variation of the "tutorial" basic example disables and enables the layer mid-frame with expected result:
Code: #include "Tilengine.h"
void rasterCallback(int line){
if (line == 128)
TLN_DisableLayer(0);
if (line == 200)
TLN_EnableLayer(0);
}
int main (int argc, char* argv[]) {
TLN_Tilemap tilemap;
int frame = 0;
TLN_Init (400, 240, 1,0,0);
tilemap = TLN_LoadTilemap ("assets/sonic/Sonic_md_fg1.tmx", NULL);
TLN_SetLayer (0, NULL, tilemap);
TLN_SetBGColor (32,32,128);
TLN_CreateWindow (NULL, 0);
TLN_SetRasterCallback(rasterCallback);
while (TLN_ProcessWindow ()) {
TLN_SetLayerPosition (0, frame, 0);
TLN_DrawFrame (0);
frame++;
}
TLN_DeleteTilemap (tilemap);
TLN_Deinit ();
return 0;
}
Posts: 195
Threads: 25
Joined: Dec 2020
Reputation:
1
(03-01-2025, 05:54 PM)megamarc Wrote: Hi,
I can't reproduce what you describe. You can disable or enable layers inside raster callbacks, and they keep in that state until you change it. Take into account that setting the type of layer (i.e. tilemaps, bitmap, objects...) automatically enables it.
This variation of the "tutorial" basic example disables and enables the layer mid-frame with expected result:
Code: #include "Tilengine.h"
void rasterCallback(int line){
if (line == 128)
TLN_DisableLayer(0);
if (line == 200)
TLN_EnableLayer(0);
}
int main (int argc, char* argv[]) {
TLN_Tilemap tilemap;
int frame = 0;
TLN_Init (400, 240, 1,0,0);
tilemap = TLN_LoadTilemap ("assets/sonic/Sonic_md_fg1.tmx", NULL);
TLN_SetLayer (0, NULL, tilemap);
TLN_SetBGColor (32,32,128);
TLN_CreateWindow (NULL, 0);
TLN_SetRasterCallback(rasterCallback);
while (TLN_ProcessWindow ()) {
TLN_SetLayerPosition (0, frame, 0);
TLN_DrawFrame (0);
frame++;
}
TLN_DeleteTilemap (tilemap);
TLN_Deinit ();
return 0;
}
Oh so that was intentional, sorry.
However it seems I have a more serious bug. Did you already tried to load an objectList from a TMX file? I have no issues under Linux, but it crashes on Windows, saying that I access invalid memory, with C# at least.
Posts: 680
Threads: 33
Joined: Jan 1970
Reputation:
13
Hi,
Can you provide a working example that reproduces the issue, with source code and assets and the following information? - Windows architecture (32 or 64 bits)
- .NET version
Thanks,
Posts: 195
Threads: 25
Joined: Dec 2020
Reputation:
1
(03-08-2025, 06:21 PM)megamarc Wrote: Hi,
Can you provide a working example that reproduces the issue, with source code and assets and the following information?- Windows architecture (32 or 64 bits)
- .NET version
Thanks,
Hi! I will send you a minimal reproductible example as soon as I can.
|