Virtual Gamepad for Platformer2D#15
Conversation
|
Note I've gone with a minimal implementation just suiting this example. |
|
My first impression from the screenshot is that the UI for this covers the gameplay. Can we do something a little better? Like maybe fade out the UI rendering after a second or once they start using the controls? @DDReaper - Thoughts? |
|
That was my first thought also, the controls are way to big on screen constantly. For this style of control it's wither going to need a loading screen or as @tomspilman says, it needs to fade out one play has started. |
|
Agreed. Will go for fading out after they've been pressed. |
…n after 4 seconds of no touching.
|
Okay, controls fade out after a successful touch. They fade back in after 4 seconds of no touching. |
|
@DDReaper - Want to give this a try before merging? |
|
Happy to do any more work as required. But as you put your fingers over the player for the most part it hard to make this super great on touch :) |
|
Yea... the game isn't really designed for mobile. I'm just letting @DDReaper make the call on this. |
Platformer2D/Game.cs
Outdated
There was a problem hiding this comment.
This should be part of the HandleInput function, not seperate
|
Looks good, made one comment about the change to Update. SHould be part of HandleInput. Also on Windows8 you are currently unable to use the new virtual gamepad. This would be a major limitation on the vast array of touch screen Windows 8 hardware. Is it possible to consume the gamepad implementation behind the Virtual Gamepad so that both can still be used? Might be better to have the virtual gamepad on my default and just disable it for non touch platforms such as Ouya, Mac and Linux. Rather than the selective platform do if !Ouya && !Mac etc. All in all very clean though and with those updates it would be great. |
|
Thanks for the review and thoughts. Will take a look at consuming the real gamepad tonight. Looks like I should be able to use TouchPanel.GetCapabilities().IsConnected to work out if there is a TouchPanel we can use. |
|
Combining them is going to be a bit clunky. I basically need the Buttons value from GamePadButtons @tomspilman Thoughts on giving Buttons a public getter? |
|
Well submit a PR to the MG repo with the change and then discuss that there. |
|
So does anything need to change here or is it good to merge?
I don't see why it is needed. Are the existing individual button state getters in that class not enough? |
|
Needs a few tweaks @tomspilman before it can merge so it's fit for all platforms |
|
Ahh, I see the issue, buttons in the GamePadButtons class is marked as internal Can you not get it from GamePadState @danzel ? |
|
The issue is: The only constructor GamePadButtons has takes a Buttons enum. I get a GamePadButtons object from GamePad.GetState(), but to get the state of the buttons I have to go through each of its public ButtonState properties and generate a Buttons enum from them. I can do this, but it's a bit clunky. It would be much tidier if we had access to GamePadButtons.buttons, but this would be breaking with XNA. The clunky way is only about 10 extra lines of code, something like: buttons |= (gpButtons.A == ButtonState.Pressed ? Buttons.A : 0);
//And so on for each buttonI'll do it this way, we keep XNA compatibility in the samples which is nice. |
|
Keeping XNA compatibility sounds like a great idea :D |
…uchPanelState.IsConnected, but apparently that is always true. Bug?
|
Have pushed up some more work on this. We only draw the VirtualGamePad if touchState.IsConnected is true, but it looks like it always is. (I tried TouchPanel.GetCapabilities().IsConnected too), might be a monogame bug/not implemented. Currently touch controls stay visible if other input is being used, will make them disappear when any input is detected. |
|
Sounds good, I'll check it out. |
|
Logged some bugs for the bad IsConnected |
|
And now the virtual controls fade out after any input, so this should be good to go I think. |
|
Don't forget about this :) |
|
Sorry... merged! |
Virtual Gamepad for Platformer2D
|
Cool, thanks :) |
Implemented a simple virtual gamepad for the Platformer2D sample.

Tested on Android, iPhone, WP8.
Fixes #10