So I’ve been writing a little tile-base turn-based strategy game (or, well, at least the tile part), and would like the tiles to have a little tag/window/menu thing pop up if you click on them (interactive that is).
a) How hard would it be to implement something along these lines? I’m still relatively new to Panda, and haven’t done anything GUI related with it yet.
b) How would I best go about doing this?
I’m sorry if this topic has been discussed before, I didn’t get very far with my search of the forums (I assume I don’t know enough to be able to search for it right). What I did find was somewhat intimidating and confusing, each thread seemed to talk about a different GUI.
B) I’m no expert at Panda GUIs, so I don’t know that this is the best way, but what occurs to me is this:
Selection of tiles.
This is likely to depend to some degree on your situation, but for a 2D layer of tiles you might be able to get the world-space selected point using this method, and then do a little maths (of a sort depending on the shape of your tiles and your specifications for their selection) to determine which tile that point indicates.
The choice of GUI system.
Panda’s built-in GUI system seems to largely work for my ends, but you may want to perform a forum search for other options - I seem to recall that other GUI systems have been offered at times.
The GUI.
This step may depend on which GUI system you choose, but what I imagine is creating a single hierarchy of GUI objects and keeping it hidden until desired. Then, on click, find the relevant tile as described above, extract any desired data intended to be displayed on the GUI, update the GUI as appropriate, then place it at the mouse coordinates (presumably not the world coordinates) and show it. Once you’re done with it, simply hide it again until the next click.
Thanks for answering. I already have 1), done pretty similarly as is described there.
My main issue is that I actually want the UI in the form of menus floating around the 3D scene more or less, and not a normal 2D GUI on top of the scene with the menus at the right places. I’ll settle for that of course if the 3D stuff is too much work, but it would be neat .
I’ve done a bit of reading up on at least showing static images in the 3D scene with cardmaker and texturing, I’m assuming now that I would go about it along the lines of rendering the GUI in 2D form somewhere, then placing this as a texture, in addition to having a collision system that would check for the mouse hitting such a menu thing, which would in turn pass the location of the collision back to the GUI. Am I more or less on the right track? Or rather, I suppose I’m asking, is there an easier way, and if not, would this work?
I suppose that it depends on how complex a GUI you want, and how strictly you want it to be “3D”. If you want text entries, sliders and the like then something such as you describe might work, although you might have trouble with matching clicking positions and the like to their visual representations, since the visual result may not be in the same place or at the same size on the screen as the underlying GUI.
Could you not perhaps fake the three-dimensionality? Use tricks of colouring to fake lighting and the world-point derived from picking to generate a screen position for the GUI, perhaps?
On the other hand, if your GUI is fairly simple (or you don’t mind a fair bit of extra work, as I suspect would likely be entailed), you might be able to employ the picking method to enable clicking on “buttons” made of cards, as you suggest, using a new picking plane.
I’m honestly not sure of whether attempting to mix picking and the actual GUI system is likely to work. My intuition is that it should, but I don’t know how easy it might be…
You have a point, I hadn’t actually considered how complex I wanted my GUI, or anything about it really past being interactive if possible 3D
I’ll just go ahead and try that with the mix of picking and actual GUI, and if that’s too much trouble I’ll go about faking it. It was more meant to be something that would be kind of cool to have, not a necessity.