A question about touch movement and onscreen buttons
Hi guys. This is my first real tech question on these forums.
I have a game with a 'touch the screen to go there' movement scheme for your character. The touch just has to be outside the PC to register.
I've also got a button at the top left corner of the screen which lets you toggle between the 'touch' movement scheme and an onscreen joystick/thumbpad scheme.
The problem is, when you touch the toggle button, it also registers as a movement touch, and sends your character moving towards the topleft corner of the screen.
I created a boolean 'block movement' attribute which, when true, stops movement touches from being registered. The thing is, even if I set this to true at the moment a player presses the toggle button, their character still has time to take a tiny step towards the topleft corner of the screen before the safeguards kick in and stop them moving. I then experimented with delaying the registering of the movement touch by fractions of a second, but even at 0.5 seconds (which I consider to be too long, anyway) the safeguards can't stop the player in time.
Is there another workaround or technique for this kind of thing someone could suggest?
One thing I thought of but had to discount was having a kind of 'carpet' object underneath everything which would specifically register the movement touches. This would solve the button problem, but I've got other mechanics in the game for which it's necessary to be able to click on a scenery object and start walking towards it - so I had to forget this scheme.
Thanks for your input.
I have a game with a 'touch the screen to go there' movement scheme for your character. The touch just has to be outside the PC to register.
I've also got a button at the top left corner of the screen which lets you toggle between the 'touch' movement scheme and an onscreen joystick/thumbpad scheme.
The problem is, when you touch the toggle button, it also registers as a movement touch, and sends your character moving towards the topleft corner of the screen.
I created a boolean 'block movement' attribute which, when true, stops movement touches from being registered. The thing is, even if I set this to true at the moment a player presses the toggle button, their character still has time to take a tiny step towards the topleft corner of the screen before the safeguards kick in and stop them moving. I then experimented with delaying the registering of the movement touch by fractions of a second, but even at 0.5 seconds (which I consider to be too long, anyway) the safeguards can't stop the player in time.
Is there another workaround or technique for this kind of thing someone could suggest?
One thing I thought of but had to discount was having a kind of 'carpet' object underneath everything which would specifically register the movement touches. This would solve the button problem, but I've got other mechanics in the game for which it's necessary to be able to click on a scenery object and start walking towards it - so I had to forget this scheme.
Thanks for your input.
Comments
http://bit.ly/xOb9mY the joystick isn't included but hopefully the switching logic is ok
I've got several toggling buttons, so I could try setting up a system where if you're clicking on any of them, the others can't grant permission. I'll try this out.
In your demo, you've got an either/or situation. You're clicking inside the button or outside. That is failsafe.
I modified it so each of the two buttons on my screen sets its own attribute when its down. Then, if you click outside one, it checks that the other one's touch attribute is also clear before it grants permission. The trouble is, the click outside registers microscopically faster than the buttons' ability to change their own status to 'DOWN', so it is still tricked into granting permission. This was tricky to bugtest - I found that removing both buttons from the game and adding them back in reverse order changes which one fails to switch fast enough. But the points is - with more than one, later ones don't change quickly enough.
I also tested if the order that objects are layered could help, but it doesn't. Putting a touch receptacle beneath the buttons, that receptacle can still receive a click faster than the button you're clicking through to reach it can change its status to TOUCHED.
So I still haven't worked out a way to do this with attributes. I may need to look at things like putting the buttons right next to each other and manually locking out a portion of the screen by coordinates, like earlier folks suggested.