Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sprite/Tile YSort effect and Camera Movement
#4
Hi!
Finally had time to check your post. Your "city.tmx" map doesn't contain any square object, is that right?
I've checked that Tilengine since release 2.5.0  can directly load "Rectangle" object type out of the box, for that purpose you can discard libtmx entirely:
This is possible because Tilengine already loads "Tile" objects, that have the same internal representation as "Rectangle" objects, but with the "gid" attribute set all to 0.

Assuming you have an object layer named "collisions", this is how to load its objects:

Code:
TLN_ObjectList list = TLN_LoadObjectList("city.tmx", "collisions");
TLN_ObjectInfo info = { 0 };
bool has_object = TLN_GetListObject(list, &info);
while (has_object)
{
    //do_whatever_with(info);
    printf("Object %d, x=%d y=%d w=%d h=%d\n", info.id, info.x, info.y, info.width, info.height);
    has_object = TLN_GetListObject(list, NULL);
}

The TLN_GetListObject() iterator is called in two different ways:
  • First time, to get "first" object, the TLN_ObjectInfo pointer must ve a valid one
  • Inside of the loop, to get "next" object, TLN_ObjectInfo must be NULL, meaining that it uses the previous one and that is a continuation.
In next release I'll expand the TLN_ObjectInfo struct to retrieve name and type standard properties, but it should work for you just as it's now. Let me know!
Reply


Messages In This Thread
RE: Sprite/Tile YSort effect and Camera Movement - by megamarc - 05-09-2020, 06:30 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)