Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Rendering ObjectLayer using tmxlite  (Read 2155 times)

0 Members and 1 Guest are viewing this topic.

grumpybear

  • Newbie
  • *
  • Posts: 2
    • View Profile
Rendering ObjectLayer using tmxlite
« on: December 22, 2019, 07:34:58 pm »
Hi, I'm currently using the tmxlite library combined with the example SFML implementation included in the GitHub readme. I'm currently able to fully render any tiled layers from Tiled but I can't render any visible objects in the Object Layer. Does anyone know an easy way to extend the code here (https://github.com/fallahn/tmxlite/blob/master/SFMLExample/src/SFMLOrthogonalLayer.hpp) to render tiled objects also? Or just a simple way to render map objects, as I can barely understand the code used in the link..

fallahn

  • Hero Member
  • *****
  • Posts: 507
  • Buns.
    • View Profile
    • Trederia
Re: Rendering ObjectLayer using tmxlite
« Reply #1 on: December 22, 2019, 11:08:44 pm »
Hi!

I'd recommend first checking out the quickstart to get the object layers from your map, followed by the objects in each of those layers: https://github.com/fallahn/tmxlite/wiki/Quick-Start

Once you have your objects you can parse them as you'd like, using the object properties available (reference here: https://codedocs.xyz/fallahn/tmxlite/classtmx_1_1Object.html )

For example you'll probably want to use getPosition() and getRotation() and then use, for example, getAABB() to draw the object bounds with an sf::VertexArray set to LineStrip or getTileID() to grab a tile from your tile set and draw it with sf::Sprite. You could also use getShape() and getPoints() to draw the object with a LineStrip, or getText() if the object has text which could be rendered with sf::Text.

HTH!

grumpybear

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Rendering ObjectLayer using tmxlite
« Reply #2 on: December 22, 2019, 11:47:41 pm »
Thanks for the help, really glad for the library too!

 

anything