Hey there, So in my game, when touch is pressed it changed game.dropball to true. However, if you tap the reset scene button while the ball is not dropped it drops the ball before it resets the scene. Any clue how to fix this?
This is a similar issue to one I'm struggling with - I find it's very hard to block actions that can be activated by a touch anywhere on the screen quickly enough when you need to (EG when you press the Reset Scene button in your game.) In your case, you'd ideally want to * block the action which sets drop.ball to true * at the moment a person clicks the reset scene button.
I see you've got two other buttons there. Are they working yet? And does a ball drop when you click on them?
If there's only one button you want to have stop the ball being dropped when it's pressed (EG The Reset Scene button), you can use a technique Rob2 showed me in my topic on this kind of problem. Download his demo in this topic:
If you want all 3 of those buttons on your screen to do different things, and for balls not to be dropped when you click on any of the 3, I haven't been able to solve that problem yet myself. The game engine reacts too quickly to the 'touch anywhere' for toggling/blocking tricks to kick in in time.
I should add I know a couple of workarounds which may or may not suit your game.
One is to put all the utility buttons in an area of the screen where you don't allow touches to register. It could be a corner, or it could be a band across the top or bottom. This definitely solves the problem.
As an example, if you put the reset button in a band at the bottom of the screen that was 50 pixels high, you'd then go to your touch anywhere rule that sets drop.ball to true, and add another condition to the rule, and make sure All conditions must be fulfilled:
attribute game.Mouse.Position.y > 50
(this would stop touches registering for the bottom 50 pixel rows on the screen)
A second solution is to add a delay to the ball drop action. For instance, if you put the 'change attribute: ball.drop to true' behaviour inside a Timer behaviour, with maybe a duration of 0.2 seconds, and tick the 'run to completion' box, the ball won't fall until 0.2 seconds after the player clicks on the screen. This might give the scene time to reset before it drops. You could tweak the timer duration to be long enough to cover it. Of course if your game involves dropping lots of the balls, the delay may be too annoying or noticeable.
@redsky Ok. Well after I posted and reloaded the page, I saw that some other people maybe helped you out. Did you figure everything out before I dive into this?
Comments
I see you've got two other buttons there. Are they working yet? And does a ball drop when you click on them?
If there's only one button you want to have stop the ball being dropped when it's pressed (EG The Reset Scene button), you can use a technique Rob2 showed me in my topic on this kind of problem. Download his demo in this topic:
http://forums.gamesalad.com/discussion/39794/a-question-about-touch-movement-and-onscreen-buttons#Item_13
If you want all 3 of those buttons on your screen to do different things, and for balls not to be dropped when you click on any of the 3, I haven't been able to solve that problem yet myself. The game engine reacts too quickly to the 'touch anywhere' for toggling/blocking tricks to kick in in time.
One is to put all the utility buttons in an area of the screen where you don't allow touches to register. It could be a corner, or it could be a band across the top or bottom. This definitely solves the problem.
As an example, if you put the reset button in a band at the bottom of the screen that was 50 pixels high, you'd then go to your touch anywhere rule that sets drop.ball to true, and add another condition to the rule, and make sure All conditions must be fulfilled:
attribute game.Mouse.Position.y > 50
(this would stop touches registering for the bottom 50 pixel rows on the screen)
A second solution is to add a delay to the ball drop action. For instance, if you put the 'change attribute: ball.drop to true' behaviour inside a Timer behaviour, with maybe a duration of 0.2 seconds, and tick the 'run to completion' box, the ball won't fall until 0.2 seconds after the player clicks on the screen. This might give the scene time to reset before it drops. You could tweak the timer duration to be long enough to cover it. Of course if your game involves dropping lots of the balls, the delay may be too annoying or noticeable.
Thanks! John actually just helped me through it and said the same sort of stuff as you
Jack McGraw