Virtual Joystick: Wiring In
Oops, My Bad!
After yesterday's planning session I had a realization. I had completed the refactor surrounding my ConfigFile use but I completely forgot about the underlying reason behind that refactor! Luckily, my planning yesterday isn't a waste, I'll still make good with those changes, but first I wanna get the virtual joystick implemented. So, that's what I'm doing today.
The first thing I needed to do was to add the player override setting. A couple of new nodes (a RichTextLabel and an OptionButton) was all I needed there. Added three choices to the OptionButton. Oh, and I also had to make some updates to my localization, it's important to keep up with this as I make changes, otherwise I might miss something and cause myself headaches down the line. Once I had the new nodes in place I had to fiddle with it to get my layout looking the way I wanted.
I ended up going with a look that isn't quite what I wanted, the label and pulldown are offset to the right of center. It doesn't look the best, but it's better than the alternatives. Once that was done, it was time to get programming! This step was actually super easy. I added a new variable to reference the OptionButton and created a new function to connect to the item_selected signal. After that was a few extra lines in ready, first to validate the OptionButton, then to set it if the setting is saved, and finally a connection to the function I created earlier.
What's Next?
With that out of the way, I think the next step is figuring out how to actually use the virtual joystick . . . Back into the UI Manager! I had previously added my reference to the PackedScene for my configured virtual joystick, but that's it. So next up was adding a variable to hold the virtual joystick once it's instantiated. After that I had to figure out the best approach to specifying which game states I should show the VJ. In the end I decided to add a simple array of game states as an export variable.
After that was an exercise in logic, which I failed. But luckily I had Gemini to assist with figuring out the best approach to determining if the VJ should actually appear. My original thought was to use a single IF statement, but that wouldn't have worked. Instead, I implemented a boolean variable, which is set based on the appropriate checks. Then I fire the appropriate function to show or hide the VJ based on that variable. Testing shows the logic seems sound, although I can't know for sure until I actually implement the showing and hiding of the virtual joystick.
Next Time
But, that part will come in the next session. To be honest, it really shouldn't be much work to implement. I just need to copy the existing code for my other UI elements and make small modifications. Then comes the testing and troubleshooting and fixing. But I'm tired, not only did I put serious work into Xenodochium, but I also put in a full day of work at my day job, and built two separate pieces of furniture for the apartment here in the Philippines.
Xenodochium
The future is what you make of it!
| Status | In development |
| Author | Munchmo |
| Genre | Role Playing |
| Tags | 2D, Cozy, Godot, Indie, Life Simulation, Pixel Art, Sci-fi, Singleplayer |
| Languages | English |
More posts
- HUD Prefab: Layout Changes4 hours ago
- Virtual Joystick: It's Alive1 day ago
- Planning Is Work3 days ago
- Refactor: Troubleshooting4 days ago
- User Config Refactor: Completed?5 days ago
- User Config Refactor: Continued6 days ago
- User Config Refactor: Planning6 days ago
- Virtual Joystick: Configuring8 days ago
- Virtual Joystick: Plugging In9 days ago
Leave a comment
Log in with itch.io to leave a comment.