![]() |
Objects list : How to use it? - Printable Version +- Tilengine - The 2D retro graphics engine forum (http://tilengine.org/forum) +-- Forum: English forums (http://tilengine.org/forum/forumdisplay.php?fid=3) +--- Forum: Support (http://tilengine.org/forum/forumdisplay.php?fid=7) +--- Thread: Objects list : How to use it? (/showthread.php?tid=982) |
RE: Objects list : How to use it? - System64 - 12-20-2020 with TLN_AddSpriteToList() and TLN_RemoveSpriteToList()? TLN_AddSpriteToList() is mentionned in the references but nothing about it RE: Objects list : How to use it? - megamarc - 12-20-2020 Hi, That's an error in the documentation, sorry. TLN_AddSpriteToList doesn't exist, It should say TLN_AddTileObjectToList(). This function is used in case you want to populate a TLN_ObjectList by hand at runtime. However you usually will use TLN_LoadObjectList() on a .tmx file with an object layer. RE: Objects list : How to use it? - System64 - 12-20-2020 TLN_AddTileObjectToList() isn't it for adding Tiles as objects in the List? also, seems there is no function to remove objects from the list, so if my ennemy generates a lot of bullets for exemple, isn't there a risk the list grows more and more? RE: Objects list : How to use it? - megamarc - 12-20-2020 This is for ading tile objects to an objectlist, in other words, to build a bitmap-based tileset (.tsx) at runtime. That's why you don't se a "destroy/delete" companion function. Once created, the tileset remains immutable until its final deletion. This function is used by the .tsx loader, that's you will usually do. It's NOT to manage an active actors llist. The actor list is a gameplay construction and must be provided by the game itself. Tilengine is a graphics engine, so it will draw, but it's not a game engine, so it won't managed gameplay mechanics for you. Take a look at python platformer project. The active actors list is entirely managed in python, Tilengine itself doesn't know nothing about it. RE: Objects list : How to use it? - System64 - 12-20-2020 I think I found important things about what I want in the cide Code: def load_objects(file_name, layer_name, first_gid): Code: class Item(object): Code: class World(object): But I have the impression that Actor.remove and world.object.remove are indefined Also, seems I need ElementTree for the code, something I probably don't have in other languages. Should I use an external library for that? RE: Objects list : How to use it? - megamarc - 12-21-2020 actorsand world.objects are standard Python lists. They have the remove() method to remove items. That's why you can't find their definitions. Python list reference: https://docs.python.org/3/tutorial/datastructures.html
https://docs.python.org/3/library/xml.etree.elementtree.html When I made this sample project, Tilengine couldn't yet load object layers from .tmx files, so I used Python xml facility to do it. Now it can load TLN_ObjectList by itself, you don't need to load it separately anymore. RE: Objects list : How to use it? - System64 - 12-21-2020 So I should treat this Tilengine's Object list as a common list? So I can use the language's list management functions? RE: Objects list : How to use it? - megamarc - 12-21-2020 Not directly. You must create a native python list, and use TLN_GetListObject() to iterate over all elements of the TLN_ObjectList returned, cloning each instance of TLN_ObjectInfo data returned, and adding them to the python list. RE: Objects list : How to use it? - System64 - 12-21-2020 I guess it's the same principle for all programming languages? Now I understand better I think Creating the list with Tilengine with TLN_LoadObjectList Creating a list with the language put everything from the Tilengine list into the language's list And if my ennemy creates bullets, I have to add a slot into the language's list and when it's destroyed, remove it from the language's list by querying its id RE: Objects list : How to use it? - megamarc - 12-21-2020 Yes! That's the way to go :-) You usually will manage two lists:
I have this effect into account in my sample project "python platformer". When the player kills an enemy -removing it from the actors list-, the spawn point that created it is also removed from the "object list". |