Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Per-pixel sprite vs tilemap collision
#1
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...
#2
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?
#3
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);
I don't clearly understand why it happens.
#4
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


Forum Jump:


Users browsing this thread: 1 Guest(s)