'touch is pressed' being pressed all at once
Feathers
Member Posts: 31
Hi guys. I have a game with upgrading features; when touch(button) is pressed you can upgrade some function.
The problem is that when touch is pressed it upgrades all the levels at once, not just one time.
For example say that I have 1000 coins, which is enough for upgrading a function 3 times.
Now, the problem is that when I touch the upgrade button it upgrades all three times and becomes lv.4 with only one touch.
I did as below.
- Made 5 boolean attributes.(goal1, goal2, goal3, goal4, goal5)-Default: false.
- Made the upgrade button's Alpha to 0.
- When game.goal2(same for all five goal attributes.) is true change attribute self.Color.Alpha to 1.
- Then I made a rule for the button to become clickable.(this is an example for goal2)
when attribute self.Color.Alpha is 1
when Actor receives event touch is pressed
when attribute game.goal1 is true
when attribute game.goal2 is false
change attribute game.goal2 to true
change attribute self.Color.Alpha to 0
I made these rules 5 times(for goal 1, 2, 3, 4 and 5) in 1 upgrade button.
Does anybody know what the problem might be? Help me please.
Comments
im use a timer in that case, dont know if there any better way.
Touch is pressed
after 0.2
change att
Homepage: freneticgamez.eu/
https://play.google.com/store/apps/developer?id=FreneticGamez
Seems like a very complex way of doing things (?), I'm not quite sure I understand the rules, can you upload a stripped down version of your project.
Here you go.
I wanted the users to know when they can upgrade something.
If collecting 200 coins is the condition for upgrading, having 200 coins will change the red button's Alpha to 1.
Whenever a red button is on screen you can just upgrade that something.
Im so sick of all these senior forum members answering questions with another question...
What you need to do is add a boolean attribute, call it "touched" make the following rules:
Rule-> if attribute "touched" = true AND if touch is pressed do -> `
-add whatever upgrade you need
-change attribute "touched" to false
new rule -> if touch is released do ->
change attribute "touched" to true.
If you don't add the "touched" boolean, you game will do the command every game tick.
But in this case, it only does it 1 time pr touch. no matter how long you touch it for.
It worked. Thanks for saving my day.
Have a good one.
Asking for additional information is generally the quickest way of resolving issues. If you prefer people to simply give you the correct answer on first asking then you can wait around for that and ignore people who ask for clarification / additional information, no harm done.