Hello! I've been trying to replace on screen buttons with gestures for my android app, but I am a bit stuck.
init:
$ config.gestures["s"] = "game_menu" #swipe down to open the menu
$ config.gestures["e"] = "skip" #swipe right to skip
$ config.gestures["w"] = "rollback" #swipe left to see previous line
#$ config.gestures["n"] = ? #swipe up to quick save
This is what I have so far. What I want to know is how to add the quick save feature as a swipe up. For the others I've been using the events found in the default keymap here. But there is no quick save there so I am a bit lost. How can I add other events such as qs or auto forward?
Another related question is: are there any other simple gestures that I can use for auto or other functionalities? Such as press and hold, two-finger tap or something similar? I know I can use L-shapes, but I just wanted to know my options.
Thank you very much for reading. Help is greatly apreciated.
Gestures on android - Hold gesture? How do I add events?
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
- GlassHeart
- Regular
- Posts: 105
- Joined: Fri Mar 11, 2011 12:13 pm
- Completed: Hand in hand with destiny, Out of Sight, Summer Found Me (Again), Signed X, Trapped
- itch: https://selavi.itch.
- Location: Romania
- Contact:
- PyTom
- Ren'Py Creator
- Posts: 16096
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
- Contact:
Re: Gestures on android - Hold gesture? How do I add events?
It's a little indirect. The right way to do this is with a screen that maps keys to actions:
And then use config.gestures to map those.
That being said - I'd really reconsider using gestures instead of buttons. They seem very confusing in practice. (The feature only exists so I can access the super-secret progress screen on Android by using a gesture-based version of the Konami code.)
Code: Select all
screen my_keymap:
key "auto" action Preference("auto-forward", "toggle")
key "quick_save" action QuickSave()
Code: Select all
config.gestures['n'] = "quick_save"
config.gestures['n_e_s'] = "auto"
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom(When was the last time you backed up your game?)
Software > Drama • https://www.patreon.com/renpytom
- GlassHeart
- Regular
- Posts: 105
- Joined: Fri Mar 11, 2011 12:13 pm
- Completed: Hand in hand with destiny, Out of Sight, Summer Found Me (Again), Signed X, Trapped
- itch: https://selavi.itch.
- Location: Romania
- Contact:
Re: Gestures on android - Hold gesture? How do I add events?
Thanks for replying, Tom.
I've tried to do as you said but the gesture was not working (all the others are working fine). I attempted to replace gestures with a random key to see if that would make a difference.
Something like this: config.keymap['auto'].append('t')
I got an error which to me sounds like "auto" is not defined properly.
While running game code:
File "game/options.rpy", line 1437, in <module>
config.keymap['auto'].append('t')
KeyError: 'auto'
For anyone wondering, I did manage to fix the problem in another way thanks to Alex by reading this post.
I defined my screen as
screen my_keymap:
key "t" action Preference("auto-forward", "toggle")
Then configured the gesture for swipe down as
config.gestures["s"] = "t"
Then showed the screen at the beginning of the game
show screen my_keymap
This also causes the key "t" to toggle auto, but since I intend to use this on mobile, it shouldn't affect it. It may not be the best solution, but it works well as far as I can tell.
I've tried to do as you said but the gesture was not working (all the others are working fine). I attempted to replace gestures with a random key to see if that would make a difference.
Something like this: config.keymap['auto'].append('t')
I got an error which to me sounds like "auto" is not defined properly.
While running game code:
File "game/options.rpy", line 1437, in <module>
config.keymap['auto'].append('t')
KeyError: 'auto'
For anyone wondering, I did manage to fix the problem in another way thanks to Alex by reading this post.
I defined my screen as
screen my_keymap:
key "t" action Preference("auto-forward", "toggle")
Then configured the gesture for swipe down as
config.gestures["s"] = "t"
Then showed the screen at the beginning of the game
show screen my_keymap
This also causes the key "t" to toggle auto, but since I intend to use this on mobile, it shouldn't affect it. It may not be the best solution, but it works well as far as I can tell.
Re: Gestures on android - Hold gesture? How do I add events?
can you share the code you used to get the gestures to work @GlassHeart, I only keep getting errors when I try to use them. It would really help me out and also we should put the code in screens.rpy, right?