0

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.

chitondihk
  • 105
  • 1
  • 10
  • What about if I grab a touch? Is it possible then to process multiple touches going at once? – chitondihk Nov 29 '16 at 09:17
  • Yes, you can do this. Kivy can process essentially any number of simultaneous touches (limited by hardware well before any software problems) - you don't have to do anything special to do so, the touch api just passes touches when it receives them. – inclement Nov 29 '16 at 11:59
  • The problem is, you keep your thumb down on the Dpad while using your other thumb to press other buttons. The touch you created on the Dpad seems to get interrupted by other touches. – chitondihk Nov 29 '16 at 16:31
  • @chitondihk then it's just your bad implementation. Each touch calls `on_touch_down`, `on_touch_up` and if the touch is held and moved, it calls `on_touch_move`. Do a good implementation (or paste your code here). – Peter Badida Nov 29 '16 at 17:10
  • Keep in mind, I am talking about the Window receiving all the touches...not button widgets etc. – chitondihk Nov 29 '16 at 17:12
  • I have an idea of what the issue could be now... – chitondihk Nov 29 '16 at 17:14
  • Kivy has no problem doing what you want. If you want help, post a minimal example demonstrating your problem with your own code. – inclement Nov 29 '16 at 17:18
  • Is there a way to identify a touch...like giving a widget an id ? – chitondihk Nov 29 '16 at 17:36

1 Answers1

-1

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

chitondihk
  • 105
  • 1
  • 10