Opening the menu on Android/Apple Devices Via Touch Input
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.
-
- Veteran
- Posts: 298
- Joined: Fri Apr 20, 2012 4:44 am
- Contact:
Opening the menu on Android/Apple Devices Via Touch Input
Hey guys, as you know, screen-space on mobile devices is precious, especially when trying to provide a cinematic experience. As such, instead of using the quick menu or an on-screen button, I'd like the menu to be shown (ie the default right-click function) if the player taps and holds anywhere on the screen for 2 seconds; is this possible?
alwaysthesamebluesky.com
- Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
- Contact:
Re: Opening the menu on Android/Apple Devices Via Touch Input
Long press (you can set duration and wobble amount (to separate from drag/swipe touches) in config) is governed by the "alternate" button action for Android, so pseudo-code example:
The configs...
define config.longpress_duration = 0.5
# The amount of time the player must press the screen for for a longpress to be recognized on a touch device.
define config.longpress_radius = 15
# The number of pixels the touch must remain within for a press to be recognized as a longpress.
define config.longpress_vibrate = .1
# The amount of time the device will vibrate for after a longpress.
Code: Select all
screen android_overlay():
# variant "android" # probably better to use renpy.variant test as below
button:
alternate ShowMenu( 'main' )
init python:
if renpy.variant( [ "touch", "android" ] ): config.overlay_screens.append( "android_overlay" )
define config.longpress_duration = 0.5
# The amount of time the player must press the screen for for a longpress to be recognized on a touch device.
define config.longpress_radius = 15
# The number of pixels the touch must remain within for a press to be recognized as a longpress.
define config.longpress_vibrate = .1
# The amount of time the device will vibrate for after a longpress.
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
-
- Veteran
- Posts: 298
- Joined: Fri Apr 20, 2012 4:44 am
- Contact:
Re: Opening the menu on Android/Apple Devices Via Touch Input
Thanks very much for this @Remix
I'd like to get it working before playing around with it but am having an issue doing so.
I guess I add this: along with the configs to screens.rpy?
And this part: just under the 'start' label (in script.rpy)?
Also, I've tested the code on an actual device, but would it be sufficient just to test it on renpy's android emulator in the future?
I'd like to get it working before playing around with it but am having an issue doing so.
I guess I add this:
Code: Select all
screen android_overlay():
# variant "android" # probably better to use renpy.variant test as below
button:
alternate ShowMenu( 'main' )
And this part:
Code: Select all
init python:
if renpy.variant( [ "touch", "android" ] ): config.overlay_screens.append( "android_overlay" )
Also, I've tested the code on an actual device, but would it be sufficient just to test it on renpy's android emulator in the future?
alwaysthesamebluesky.com
- Imperf3kt
- Lemma-Class Veteran
- Posts: 3797
- Joined: Mon Dec 14, 2015 5:05 am
- itch: Imperf3kt
- Location: Your monitor
- Contact:
Re: Opening the menu on Android/Apple Devices Via Touch Input
The android emulator will not emulate alternate clicks if you use renpy.variant in that manner.
You'll have to continue testing on an actual android device or test without the variant check.
You'll have to continue testing on an actual android device or test without the variant check.
https://www.renpy.org/doc/html/other.ht ... py-versionThese are only set when running on the actual devices, not when running on in the emulators. These are more intended for use in platform-specific Python. For display layout, use screen variants.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
Twitter
pro·gram·mer (noun) An organism capable of converting caffeine into code.
Current project: GGD Mentor
- Remix
- Eileen-Class Veteran
- Posts: 1628
- Joined: Tue May 30, 2017 6:10 am
- Completed: None... yet (as I'm still looking for an artist)
- Projects: An un-named anime based trainer game
- Contact:
Re: Opening the menu on Android/Apple Devices Via Touch Input
For the time being (while testing) just throw it all in script.rpy outside of any label block... Once you get it working as wanted, maybe separate the parts and put in other files (personally I'd put both the screen and python: config.overlay bits in screens and the config in options)
Note: You might need to change the ShowMenu call... cannot offhand remember the label name myself, it maybe "_game_menu" or somesuch
Note: You might need to change the ShowMenu call... cannot offhand remember the label name myself, it maybe "_game_menu" or somesuch
Frameworks & Scriptlets:
- Speech Bubble dialogue system
- Multiple Notify with ATL and history
- (WIP) Radial Masking - needs updating to use Shader
- 7.4 - Smooth Tinting using ATL and matrixcolor
- Several other repositories there too
-
- Veteran
- Posts: 298
- Joined: Fri Apr 20, 2012 4:44 am
- Contact:
Re: Opening the menu on Android/Apple Devices Via Touch Input
Ah, that could be the issue! Well according to this page here: https://www.renpy.org/doc/html/keymap.html, the command should be 'game_menu', but when I change the code to:
I'm getting the following crash when running it on my phone:
https://puu.sh/z8gPf/c3e85628e0.png
https://puu.sh/z8gOk/245016191c.png
Do you have any idea why?
Code: Select all
button:
alternate game_menu( 'main' )
https://puu.sh/z8gPf/c3e85628e0.png
https://puu.sh/z8gOk/245016191c.png
Do you have any idea why?
alwaysthesamebluesky.com
-
- Miko-Class Veteran
- Posts: 758
- Joined: Tue Jun 22, 2010 12:54 am
- Completed: Christmas
- IRC Nick: DragoonHP
- Location: Zion Island, Solario
- Contact:
Re: Opening the menu on Android/Apple Devices Via Touch Input
You want ShowMenu("save")[\b] instead of game_menu
-
- Veteran
- Posts: 298
- Joined: Fri Apr 20, 2012 4:44 am
- Contact:
Re: Opening the menu on Android/Apple Devices Via Touch Input
Thanks - I'm no longer getting an error, but the code still doesn't seem to be working
alwaysthesamebluesky.com
-
- Miko-Class Veteran
- Posts: 758
- Joined: Tue Jun 22, 2010 12:54 am
- Completed: Christmas
- IRC Nick: DragoonHP
- Location: Zion Island, Solario
- Contact:
Re: Opening the menu on Android/Apple Devices Via Touch Input
What are you testing on? Emulator or an actual device?
If you are using the emulator, alternate is triggered by right click on the button
If you are using the emulator, alternate is triggered by right click on the button
-
- Veteran
- Posts: 298
- Joined: Fri Apr 20, 2012 4:44 am
- Contact:
Re: Opening the menu on Android/Apple Devices Via Touch Input
Actual device - although trying to trigger it by right-clicking in the emulator also isn't working
alwaysthesamebluesky.com
-
- Miko-Class Veteran
- Posts: 758
- Joined: Tue Jun 22, 2010 12:54 am
- Completed: Christmas
- IRC Nick: DragoonHP
- Location: Zion Island, Solario
- Contact:
Re: Opening the menu on Android/Apple Devices Via Touch Input
Can you give it a normal action too and see if that is triggering?
-
- Veteran
- Posts: 298
- Joined: Fri Apr 20, 2012 4:44 am
- Contact:
Re: Opening the menu on Android/Apple Devices Via Touch Input
Sorry, I'm a bit of a n00b with this stuff, by normal action, do you mean something like the 'show' command? If so should I remove the 'button:' line too?
Looking over the code again, where is the check for the 'longpress'? What's triggering the button's action at the moment? Do we not need some sort of conditional statement?
Looking over the code again, where is the check for the 'longpress'? What's triggering the button's action at the moment? Do we not need some sort of conditional statement?
alwaysthesamebluesky.com
-
- Miko-Class Veteran
- Posts: 758
- Joined: Tue Jun 22, 2010 12:54 am
- Completed: Christmas
- IRC Nick: DragoonHP
- Location: Zion Island, Solario
- Contact:
Re: Opening the menu on Android/Apple Devices Via Touch Input
This:
Code: Select all
screen android_overlay():
# variant "android" # probably better to use renpy.variant test as below
button:
alternate ShowMenu( 'main' )
action ShowMenu("load")
-
- Veteran
- Posts: 298
- Joined: Fri Apr 20, 2012 4:44 am
- Contact:
-
- Miko-Class Veteran
- Posts: 758
- Joined: Tue Jun 22, 2010 12:54 am
- Completed: Christmas
- IRC Nick: DragoonHP
- Location: Zion Island, Solario
- Contact:
Re: Opening the menu on Android/Apple Devices Via Touch Input
No. Try with a simple left click/tap to see if anyything loads.
If nothing loads, that means the screen isn't showing up.
If nothing loads, that means the screen isn't showing up.
Who is online
Users browsing this forum: No registered users