Problem with On/Off button mechanic

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

Best Answer

  • tatiangtatiang Posts: 11,949
    Accepted Answer
    Agreed, 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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Can you send me your project file to look at? There's probably something obvious that needs to be adjusted but I wouldn't know without seeing the rules.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • dkatz621dkatz621 Member Posts: 9
    I have no idea what I did. I remade the rules in a new file, since my game file is big and confusing, so you can see only the rules attached to it. And it works in the separate file. Now when I put it back in the regular game it works....but nothing changed.....poltergeist?
Sign In or Register to comment.