Dont let player hold down touch, make player actually have to tap twice...
Hi all, this is the first game I have started to make with GameSalad or at all for that matter and have found it pretty easy to accomplish everything that I've wanted with all the great help and community support provided here. Forgive me if I am wrong, and also forgive me for the long explanation I am trying to make it straight forward yet detailed; but I haven't been able to find a forum that addresses my question so I'll ask it here:
I think there should be a very simple solution but I cant seem to solve it. Basically (to its simplest explanation) I have an actor attribute (an integer set to 2 called actor "life"), within obviously an actor. For explanations sake this actor is a cement block named "cement block". When this actor is touched the actor image changes to "cracked cement block", and when the actor is touched a second time the cracked cement block disappears.
Here's the "coding"...
Rule: When [touch] is [pressed]
Do:
... Change attribute [self.image] to [cement block cracked]
... Change attribute [self.life] to [self.life -1]
So by now the actor has changed to a cracked block and its life is down to 1...
Now comes the problem, after this action takes place I have a rule,
All is true:
Rule: When [touch] is [pressed]
If [self.life] = 1
Do: Destroy actor.
Now all is fine and dandy, this works as wanted if the player taps twice HOWEVER, it ALSO works and skips right to destroy if the player holds down touch on the first image. I want to place some sort of timer I assume?? to make it so that the player cant hold down touch and has to actually tap the actor twice to make it switch between images and then disappear.
ADDITIONAL NOTE: I have already found that by changing the rules all together so that when the original block is touched the actor is destroyed and it spawns a completely different actor with the cracked image in its place... and when this cracked actor is touched it is destroyed. This solution works as I wanted and prevents the player from holding down the touch and forces them to actually tap twice. HOWEVER I am trying to cut down on game size and increase performance by replacing multiple actors with one actor that just has its image change with instances/rules ... sooo I still need your help GS community!
If my explanation wasn't clear feel free to ask some questions! Thanks again!
Comments
@maxkallabay Change the attributes when touch is released not when pressed:
Developer For BLUNTentertainment - Feel Free To Message Me! - Free Beginner Templates!
Thank you for the quick reply @SmokeyAce73, though I had tried this before and it was unsuccessful I just realized something thanks to you!
Basically for anyone else having the same problem, both sets of rules were satisfied by the same instruction which was when pressed complete their action.. when pressed once, the actor would change to a cracked image, and lose a life. However at the same time while the players finger is down, the second set of rules is also satisfied because now the image is of the cracked block and actor attribute life=1 and obviously touch is pressed..this leads to one touch skipping right to the actors destruction.
Likewise, if I had set both sets of rules to do their actions when touch was released the same skipping of steps would lead to the actors destruction on the first press (or when touch was held down).
BUT!! and this is where you came in @SmokeyAce73, I realized if the first set of rules was changed so that it stated "released" instead of pressed, and the second set was left as "pressed"...
1st set of rules:
Rule: When [touch] is >>>>>[released]<<<<<
Do: ... Change attribute [self.image] to [cement block cracked] ... Change attribute [self.life] to [self.life -1]
2nd set of rules:
All is true: Rule: When [touch] is [pressed] If [self.life] = 1
Do: Destroy actor.
The second set of rules could no longer happen simultaneously with the first as was the problem before leading to immediate destruction on touch, or when the player held down touch because now the even though the 2nd set of rules remains the same and still only takes effect after the first set of rules, obviously you cant be touching and releasing at the same time, requiring two separate and distinct taps!! Wahoo!
Thanks again @SmokeyAce73
Glad I could be of assistance @maxkallabay
Developer For BLUNTentertainment - Feel Free To Message Me! - Free Beginner Templates!