buttons on android/mobile

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

buttons on android/mobile

Post by SwordPlay »

how do buttons work on android/mobile?

On the wiki it states:

"The Android port overlays a virtual gamepad on the screen consists of up, down, left, right buttons on one side and between zero and six buttons on the other which can be mapped to keyboard keys of your choice."

I want to add buttons.
How does one do this?

EDIT
How does diagonal input work on a touch-screen? Well?
Last edited by SwordPlay on Sat Apr 22, 2017 7:57 am, edited 1 time in total.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

To change the button mappings, go to General Game Data -> Platform-specific options, and change the Phone/Tablet virtual gamepad options.

Moving diagonally might require pressing two arrows keys at once, requiring a multi-touch device. Or maybe not, I don't know. Try it.
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Diagonal movement just means touching the space between two arrow keys. They both get activated.

You can see it in action by playing one of the ohrrpgce games already in the app store.
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

Thanks guys!

When I play OHRRPGCE games on my tablet, it looks blurry!
Is there a reason for this? Can it be changed? Could an end-user toggle this, for example?
Last edited by SwordPlay on Mon Apr 24, 2017 7:30 am, edited 1 time in total.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

I guess you're talking about the upscaling of the graphics. How bad is it? I was originally worried about it, but at least on my own phone, which has a 320x240 screen, the upscaling only affects every 5th row of pixels, and is rather difficult to notice and probably looks better than nearest-neighbour interpolation would. Maybe on a high-resolution device it's a completely different story.

There's currently no option to switch to nearest-neighbour interpolation, but it would probably be possible to add one if needed.
User avatar
Rogissidor
Slime
Posts: 22
Joined: Tue Apr 11, 2017 12:25 pm

Post by Rogissidor »

Button placement and scaling should be an option for the end user if the dev enables it. At least have a few options and support vertical screen orientation. I tried to play Vikings and the dpad covers the character portraits. It didn't respond anymore after the first few text boxes but that's probably another issue.

I'd really like a 1:1 scaling option and a Game Boy looking overlay.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Hello;
An option for users? Do you mean something that can be added to the game's main menu, like Fullscreen/Windowed and Volume? Or something that lives in a separate engine builtin menu? (The SDL Android port does actually have an options menu, displayed before the game starts, which we disable since not many of the options are appropriate and it looks awful to put a config menu there.)

Displaying an overlay on the screen would be easy, but then we would need to make the effective position of the buttons match where they are drawn on the overlay, which could be a pain.

Allowing vertical orientation and using 1:1 scaling are things that can be enabled when packaging the app, by editing a config file. I think they might also be options in that SDL config menu. Creating a way to toggle them at run-time is not very trivial.

There is a setting in the Platform-specific options menu called "Touch Textboxes", which causes the on-screen gamepad buttons to disappear when a textbox is up. I don't know why this is off by default, but as can as I can tell (James implemented this), all OHR RPGs will want to turn it on. I assume you just downloaded the regular copy of Vikings, which was never adjusted for Android (which probably just requires turning on this one setting).

I strongly dislike having the buttons overlaying the screen; if you have a phone or tablet with a large screen then it would certainly make sense to devote screen space to the buttons, or maybe a way to hide them. Which should definitely be player options, since we can't easily tell if it's appropriate.
Last edited by TMC on Mon Apr 24, 2017 2:34 pm, edited 1 time in total.
User avatar
Bob the Hamster
Lord of the Slimes
Posts: 7658
Joined: Tue Oct 16, 2007 2:34 pm
Location: Hamster Republic (Ontario Enclave)
Contact:

Post by Bob the Hamster »

Welcome, Rogissidor!

I think the quality of the scaling varies from phone to phone and tablet to tablet. It looks pretty good on my devices (not particularly blurry) but I have only tested a few different devices

I would love to make the positions of the buttons and virtual gamepad customizable in the game-- but I have not yet figured out how exactly they work in sdl-android. I don't think sdl-android is currently capable of changing them at runtime, I think they can only be changed at build-time (and I haven't figured out that yet either). I think that sdl-android had a half-finished re-write of virtual gamepad customization, which got abandoned, or something, because a lot of the virtual-gamepad related code that I was able to find seemed to do nothing when I tried modifying it.

Yes, the "Touch Textboxes" feature should probably be turned on by default, as well as the option to hide the virtual gamepad when suspendplayer is active (which gets ignored when a script is checking keypresses)

I did not turn them on previously because they needed more testing, but I think they are probably tested well enough now that they are safe to be default.
User avatar
SwordPlay
Chemical Slime
Posts: 966
Joined: Sun Jan 22, 2017 9:32 am
Location: London, England
Contact:

Post by SwordPlay »

I think I asked this before but: can slices appear outside of the screen bounds?
For example, to create a frame?

EDIT
Yeah, I tried playing Void Pyramid on my tablet, and it looks really blurry!
And it has no display options!
It'd be good to have options for mobile users to sort out their screen issues, such as resolution, orientation, padding, button placment, scaling etc.,

EDIT
On a similar note, would it be possible to have map movement via clicking?
I made a script that allows a hero to move into an adjacent tile when it is clicked, but I think actual pathing would be too complicated and intensive. Could we have something, like, how NPCs chase the player, but instead for a hero to walk to a clicked tile?
Last edited by SwordPlay on Tue Apr 25, 2017 12:09 am, edited 2 times in total.
User avatar
Soule X
Red Slime
Posts: 86
Joined: Wed Sep 19, 2012 4:18 pm
Location: Indianapolis

Post by Soule X »

I don't think that's possible but you can easily simulate it by putting a slice border around the screen. It wouldn't shrink the screen down, though, so you would be blocking tiles. You could also raise the resolution, although that comes with its own issues depending on what you're doing.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Yes, you could easily script a frame around the screen yourself by increasing the resolution and using slices, but there are lots of problems: doesn't show in battles, fades out when the screen fades, can't see the edge of maps set to "Crop", and not visible on the titlescreen.

It sounds like it would be better to default to nearest neighbour scaling. Alternatively, use smooth scaling at low resolutions (say <= 2x or 3x the game resolution) and NN at higher resolutions. I'm not sure where to put the threshold.
Does anyone have a phone with resolution in the range of roughly 640x400 to 1000x600 who can report whether it looks blurry?

OK, let's just turn Touch Textboxes on for all games (since it's impossible to have explicitly turned it off).

Map movement via clicking is planned, especially for use on phones. James has been talking about implementing pathfinding for that purpose.

It sounds like we do need a whole builtin menu for these sorts of options. It could be displayed as a regular in-game menu which you could add to the main menu, but I'm not sure how to allow access to it in existing games (if you're just using the generic android OHR player). Hmm, maybe it could even be added by default to all existing games: it'll be hidden in non-Android games, and Android games need to be repackaged when they're updated, so you can change it then.
Last edited by TMC on Tue Apr 25, 2017 1:25 am, edited 2 times in total.
User avatar
Taco Bot
Meat, Cheese, and Silicon
Posts: 484
Joined: Fri Jul 18, 2014 12:15 am
Location: Santa Cruz
Contact:

Post by Taco Bot »

My screen res is 960 x 540, and Void Pyramid looks like this for me: http://i.imgur.com/mVEBELy.png

Not particularly blurry, unless you're talking about the bilinear filtering. Tbh, I've never been a fan of it either, but I feel like most people don't like to have the game letterboxed on all sides so ymmv.
Last edited by Taco Bot on Tue Apr 25, 2017 4:57 pm, edited 1 time in total.
Sent from my iPhone
Post Reply