How to create a on or off button
Phoenix256
Member Posts: 42
I'm trying to make a button that turns the music on and off and when its on turns into a different image than when its off. So I tried use change attribute to change the Boolean (Button) to true, and that works fine, but I try to do the same to make it change back it changes for a second and then it quickly changes back. So does anyone know what I should do?
Comments
Try something like this.
Sorry that might have helped but I can't download that due to bad internet, any other ideas
Try this rule for boolean attributes:
Ok that seems like a good idea I will try that, thanks
Ok, I have tried a lot of different ways to do it, and every time I can make it change the image, but I can't figure out how to change it back, how do I change it back.
@RThurman just showed you how. If touched if changes a boolean to true, if touched again it changes it to false etc.
Fortuna Infortuna Forti Una
ugh
Maybe its the other part you are having an issue with? That is, how to do one thing when the boolean attribute is true, and do another when it is false? That goes something like this:
how do I do that otherwise, because it will change the picture but it wont change back when I press it again
See that little "otherwise" button in @LoveJoy's picture?
well mine looks different, in the rule it says "do" and below that it says "other" and I don't even know what that's for.
my bad it says else below do not other
@Phoenix256
Create button
Make an integer attribute called "game.onoff"
Rule:
When touch is pressed change game.onoff to (game.onoff +1)%2
The game.onoff will switch between 0 and 1.
So when game.onoff is 0 it will be off
When game.onoff is 1 it will be on.
ok I will try that
it didn't work any thing I try I can get it to change but I press it again it does nothing
This will produce the effect you're looking for, with optional intelligent starting/resuming:
Project also attached for anyone who wants it. The music in it freaked my cat out majorly, so be warned!
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
When we say "otherwise" it means the "else" section in windows creator.
Fortuna Infortuna Forti Una
good that's clearified
There is either something I'm doing wrong or my gamesalad program doesn't work wright, because no matter what I do I can change the image but I cant make it change back
Lets try it with 3 separate rules:
I already tried that and when I press it changes the image but when I press it again it quickly switches to the first image then right back to the other
i think my problem is the button is not changing from true to false back to true.
because when i press it it changes to true, but when i press it again i don't think its changing back to false
I showed you the exact logic needed in pictures. Can you show us the logic you are using?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
i cant upload the image i don't know if im doing it right, but i past the url to the embed thing but it doesn't bring up the picture
Just paste the URL of the picture into a post then and we'll click through to look it.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
C:\Users\Lester\Pictures\Screenshots\Screenshot (5).png
C:\Users\Lester\Pictures\Screenshots\Screenshot (6).png
there are two parts of the picture
Ah, you will need to upload them to an image host, such as http://www.imgur.com before we can see them.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
im using school internet and the site is blocked
here is the way i have it set up