Problem with On/Off button mechanic
dkatz621
Member Posts: 9
Hey everyone! I'm having an issue with an on and off button. I watched the tutorial and copied the format, i.e. making a game attribute and then having when touch is pressed and inside change the attribute to (attribute+1)%2 and put in the corresponding images.
Now the button part works, hell even the constrain image to table i worked into it works (i.e. the push the button and depending on variable y either image 1,2,3,4 displays) and when you click it again it goes back to the original image.
The problem is with the score change. I want the player score to decrease by 500 each time the press the original image. So what I did was make a rule that when the variable is 0, i.e. off when touch is pressed inside change player score to player score - 500.
However, each time the button is pressed, no matter what image is displayed, it keeps taking away 500 points every time, even though it is only supposed to take points away when the original image is displayed. I've tried re-coding it several different ways, but no matter what I do I cant fix it. Any thoughts?
Dan
Now the button part works, hell even the constrain image to table i worked into it works (i.e. the push the button and depending on variable y either image 1,2,3,4 displays) and when you click it again it goes back to the original image.
The problem is with the score change. I want the player score to decrease by 500 each time the press the original image. So what I did was make a rule that when the variable is 0, i.e. off when touch is pressed inside change player score to player score - 500.
However, each time the button is pressed, no matter what image is displayed, it keeps taking away 500 points every time, even though it is only supposed to take points away when the original image is displayed. I've tried re-coding it several different ways, but no matter what I do I cant fix it. Any thoughts?
Dan
Best Answer
-
tatiang Posts: 11,949Agreed, poltergeist.
I find that when I have to rebuild a project file, it usually ends up working better and being more efficient than the original file because I find different ways to code things.New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Answers
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User