I'm using Swift 5, SpriteKit, SKTileMap. I would like to use the equivalent of a popover. I'm using this term, because I use popovers rather frequently in other apps. Basically, a small window appears, and you read something and press OK, or maybe add a little information and press OK. What I'm trying to figure out how to do is something similar in SpriteKit.
The objective is, I want a user to long press a tile, and a small box pops up with information about the tile. What is the terrain? What resources are there? Is there a city? Is a player there? etc. It doesn't HAVE to be a view, but I'm guessing that's the way to go, because not only could there be quite a bit of text, I could see there being a button to dismiss, and maybe some tiny graphics, like a symbol corresponding to the resource, etc. Here's what I have already. I have a working long press gesture recognizer. I can already print all of the information I want to the console on the simulator. What I need to figure out is a few things.
- required: create the window and fill it with information.
- optional: anchor to tile and/or center in the screen. I haven't decided best solution yet.
- optional: dim background (probably just some alpha tweak)
The current code I have actually works very smooth. I have a good camera pinch to zoom and a good pan gesture. I load my map from a JSON file. I actually load it into a core data, database, and draw from a query against the database. That way, if you do any action, it just hits the database. What's on tile 5,5? just query the database. It works nice. I just don't know how to do the popover window in SpriteKit. I tried adding an actual popover to the content view my map is in, but it just dims the screen a little. I don't think that's a good anchor.