Search code examples
androidkivyd-pad

Kivy - Creating A Virtual Dpad


Is it possible to create a virtual on-screen Dpad in a kivy app? I don't see it as being possible because the Window only accepts one touch event at a time it seems, so there's no way to have a Dpad along with two action buttons (using images on the canvas, not actual button widgets).

I even thought about having a label accept the touch for the Dpad but drawing the actual image of the Dpad over the label would cause the label to not catch any touches (guessing).

I then thought about creating a smaller window in the corner, which might register its own touches but I haven't seen anything in the kivy docs about create a window withing the main window.


Solution

  • Solved it. The issue wasn't my code, no surprise, been programming for years. Coming up with logic is the easy part. My problems occur because of lack of understanding of API set being used. It's like being in a tool shed using a hand saw to cut wood while not knowing there's a powered chain saw over in the corner, covered up by wooden boards.

    I didn't know there was a way to 'id' a touch, thus separating them. Now that I can identify one touch from the next, everything looks good. I just have to work on my "Dpad" until it feels fluent enough. That part isn't so easy because you want the right position of the Dpad on screen and you want very little movement in order to change direction...or a player's thumb will be sliding all over the screen, lol. With my experience, I feel I'll get it perfect soon enough.

    Kivy is tricky, period. I noticed if you don't assign an id value to touch every time, the id it self will not exist (but it does!) and that will raise an exception. That's weird because you're using an attribute that already exits within touch, so why not return 'None' for an unassigned instead?

    Oh well, at least I can stop slipping that rope around my neck. :D