Tilengine - The 2D retro graphics engine forum

Full Version: tile_info.type returning 0?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, I'm trying to get collision to work with the forest sample. I've added types to the tileset in Tiled, but when I go to get the tile type using
TLN_GetLayerTile (LAYER_FOREGROUND, 11*16,12*16, &tile_info);

the number I entered in the tile type in Tiled doesn't show up, I only get a 0 returned when I print it using std::cout << tile_info.type << std::endl;

Is this a bug, or did I do something wrong?

This is my tileset file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.10.2" name="tileset" tilewidth="16" tileheight="16" tilecount="240" columns="20">
<image source="tileset.png" trans="ff00ff" width="320" height="192"/>
<tile id="67" type="2">
  <properties>
  <property name="type" type="int" value="2"/>
  </properties>
</tile>
<tile id="68">
  <properties>
  <property name="type" type="int" value="1"/>
  </properties>
</tile>
<tile id="69">
  <properties>
  <property name="type" type="int" value="1"/>
  </properties>
</tile>
</tileset>
Hi,

I can't reproduce the issue. Using your modified tileset and writing the following queries:

Code:
TLN_TileInfo tile_info = {0};
TLN_GetLayerTile (LAYER_FOREGROUND, 10*16,12*16, &tile_info);
printf("tile_info.type=%d\n", tile_info.type);
TLN_GetLayerTile (LAYER_FOREGROUND, 11*16,12*16, &tile_info);
printf("tile_info.type=%d\n", tile_info.type);
TLN_GetLayerTile (LAYER_FOREGROUND, 12*16,12*16, &tile_info);
printf("tile_info.type=%d\n", tile_info.type);

Produces the expected output:

Code:
Tilengine v2.15.1 64-bit release built Apr 23 2023 19:27:20
tile_info.type=2
tile_info.type=1
tile_info.type=1
Must be an error in how I'm writing the print code in C++, once I switched to your C code for the print the error went away.

Thank you so much