Recommended Posts

I was fiddling with the Tiled plugin, trying to get it to work with object layers. I've managed to get the plugin not to crash with non-data layers and it properly finds the name of the object, along with its properties.

My question is, how can I create an entity from it?


For example: I created a class called "Troll" in my game. I created an object named "Troll" in Tiled.

My naïve approach was calling

new game[layer.objects[num].name]()

but that, clearly, didn't work. I've attached a sample project. The code that handles object initialization starts at line 84.

Share this post

Link to post
Share on other sites



It seems that Troll class gets created, but you are adding it's sprite to stage, and after that you are adding your tilemap into stage.

This way Troll gets below your tilemap, so that's why you don't see it.


One way would be to make containers for your map and trolls etc.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.