Help for a newbie: Qt c++ and Tiled

(Nicolas) #1

Hi guys,

I am quite new to Qt and I need to create a 2D game, I used the Tiled tool which is great to make my map. But I really don’t understand how to read and display that map in my Qt project, even though I checked the github already, it seems rather complicated for what I have to do. Please any help would be great, but as I told you I am quite new to this. I am doing an AI project to train a model to play the game and win.


(Thorbjørn Lindeijer) #2

Did you check out the TMX Viewer application in the Tiled repository? It’s a small example of how you could use libtiled to load and render a map based on QGraphicsView.

Good luck with your project!

(Nicolas) #3

Thanks for your answer, I cloned the git and tried to understand a bit of the code, but I don’t unfortunately.
I did not manage to use QXmlSimpleReader to read my map, but I don’t see how I am suppose to use the TMXviewer either…
why is it launching Tiled when running?
Maybe I am better off trying to create the map directly on qt don’t you think? I am really a beginner.


(Thorbjørn Lindeijer) #4

Because Tiled is the main application in the project, and the only one for which a run configuration is created by default. If you want to run the TMX Viewer:

  • Go to Projects mode
  • Click the “Run” item under your active Kit
  • At “Run configuration” on the right, click the “Add” button and choose “tmxviewer”
  • Now clicking the Run button should launch the TMX Viewer

Of course you may be better off learning a bit more about Qt first, and possibly using QGraphicsView or maybe even just QPainter to draw your map.

(Nicolas) #5

Thank you for those usefull details, I managed to make it work !
thank you for the tool and for the answers !