How do I get a button working on mobile?

Get help using Construct 2

Post » Sun May 14, 2017 11:28 pm

Ok, so I know that the subject sounds incredibly dumb, but I couldn't fit exactly what I needed help with into a few words...

What I really need help with is finding out how to make an invisible button (or sprite that acts as a button) that has an event triggered every so many seconds that the button/sprite is being held down. Specifically, I'm making a side-scrolling airplane/dogfight game, and I want it to be playable on mobile devices. I already have it so that the start screen can tell whether to load in the mobile or keyboard layout for the full game, but I can't figure out the controls. I tried making blank sprites that scrolled with the view of the player (one on the bottom, one on top) for movement (up and down), and then making a sprite that acted as a "fire" button. I then used "System - Every tick + Touch - Is touching (Sprite) > Player - Move 5 pixels at angle 90", which is what I had for the keyboard, but replacing the arrow key with "Touch - Is touching (Sprite)". I also did basically the same thing for the "fire" button sprite; but none of the "button-sprites" worked on my mobile device. I then thought that maybe conventional Button objects might work, but when going to place the condition for it, I realized that there was no "Is holding down" on the button...

If anyone has any ideas please share them with me, as I accept that my event "coding" may have been off, or that i just haven't thought of everything. I'm sure this is a common problem, so someone should probably see this and have a simple solution.

Thanks -
Posts: 8
Reputation: 615

Post » Mon May 15, 2017 12:49 am

You can always use this workaround:
Code: Select all
- (Condition) Is touching object [Button]

If you are using the mouse, you can use this:
Code: Select all
- (Condition) Mouse is over object [Button]
- (Condition) Left mouse button is down

Also, a little side note:
DKinGer wrote:"System - Every tick + Touch - Is touching (Sprite) > Player - Move 5 pixels at angle 90"

You can remove the Every tick condition, see why here.

Also, one last thing:
If you're asking questions that are specific to your project, try to always attach a .capx of your project.
It helps the community to understand your problem better and thus, it helps you to get a faster and better response.
"We can't solve problems by using the same kind of thinking we used when we created them."
- Albert Einstein
Posts: 528
Reputation: 7,091

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 74 guests