PDA

View Full Version : tile mapping in qt?



even821
16th November 2012, 07:39
i am currently writing a tile editor for my game engine using qt, and i just have to check if im doing the tiling the best/smartest way, or if i should rewrite it.

right now my tiles are a custom graphics item that i created, and it has a mousepress event that changes the image on the tile to whatever the current selected tile is. it works and all but i have a few things to clear up before i continue coding on it:

1. is this a stupid approach? if so, what is a better way of doing it?
2. right now i have to manually click on every tile item to change them, and it worries me. is it even possible to do stuff like a pen, fill bucket etc etc doing it this way?

thanks for any help :)

wysota
16th November 2012, 09:33
I would probably handle all (or most) user interaction in the scene or in the view, leaving the interaction in the item only for item specific things.

even821
16th November 2012, 09:42
care to explain a bit more detailed, i'm not quite sure i understand, sorry :(

wysota
16th November 2012, 10:07
For example changing the tile image should be easier handled by overriding mousePressEvent for the scene rather than for the item. This is a generic action, not tied to the type of the tile (assuming you can have more than one tile type).

even821
16th November 2012, 12:35
hmm, how can i have the mousepress event on the scene then? could i create the scene as well through a custom item?

wysota
16th November 2012, 14:14
Items are in the scene, not the other way round. Have a look at QGraphicsScene and what it offers.