04-23-2020, 02:43 AM
Are you planning to add native sprite vs tilemap collision detection? I have tried to reproduce method with GetLayerTile and height masks, but it is too buggy...
Per-pixel sprite vs tilemap collision
|
04-23-2020, 02:43 AM
Are you planning to add native sprite vs tilemap collision detection? I have tried to reproduce method with GetLayerTile and height masks, but it is too buggy...
04-24-2020, 01:12 AM
Sorry, I don't understand the question. There's no such thing as sprite vs tilemap collision. You use TLN_GetLayerTile() to gather information about the playfield around specific locations, and take corresponding action in gameplay. Why do you think is this buggy? Can you please upload your test project to the forum to see what or why is wrong?
04-24-2020, 02:17 AM
For example, I must call GetLayerTile() deducting window height from ypos to make it detect tiles.
Code: TLN_GetLayerTile(LAYER_FOREGROUND,x,y-HEIGHT+19,&tileinfo);
The x and y parameters must be of one of the collision points of the game entity in world space, not in screen space. The number and distribution of collision points depends on gameplay design, it's not a Tilengine specific issue. Screen space depends on layer position set with TLN_SetLayerPosition(), whereas world space is absolute and is where actual gameplay occurs.
If you need per-pixel accurate height -used for example in Sonic irregular terrain-, TLN_TileInfo struct contains xoffset and yoffset members (collision point inside the tile) that you can use to look-up into a heightmap for the given tile id. This is however an advanced topic that shouldn't be atempted unless basic gameplay mechanics are working. Check out this thread, another user was requesting for a similar question that may help: http://tilengine.org/forum/showthread.php?tid=536 |
« Next Oldest | Next Newest »
|