User Tag List

Results 1 to 6 of 6

Thread: Toggle an in-game setting

  1. #1
    Clicker Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)iOS Export Module (Steam)

    Join Date
    Sep 2008
    Location
    Western Australia
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Toggle an in-game setting

    I have created a "Mute" key in my game, so that when the player presses 'M' on the keyboard, the sound will go off, and when 'M' is pressed again it will go on. I have achieved this by detecting the keypress, toggling the flag of an object and then setting the master volume to 100 or 0 depending on the state of the flag.

    To avoid using an object's flag, I initially tried to do it by changing a global variable (e.g. to 0 or 1) and reacting to the global variable, but I cannot achieve a toggling effect. I tried the 'obvious' conditions, e.g.

    Upon pressing M & Mute = 0 : Main Volume = 100
    Upon pressing M & Mute = 1 : Main Volume = 0

    I then tried various limit conditions along with the above, but once the value has toggled one way, it won't toggle back. I am guessing that it is because the value is toggling, then the next test is occuring and immediately toggling back, but I am not sure.

    Is there an obvious solution to my problem?

    Incidentally, I thought I had asked this question recently, but I have searched my posts and can't find it, so I apologise if I have posted it and someone has already answered.

  2. #2
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Toggle an in-game setting

    http://www.clickteam.com/epicenter/ubbthreads.php?ubb=showflat&Number=176557
    Working as fast as I can on Fusion 3

  3. #3
    Clicker Fusion 2.5

    Join Date
    Dec 2009
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Toggle an in-game setting

    You need to put a small delay in between the key presses.

    You could use the EVERY function, like EVERY 20th of a second AND key M is pressed then do whatever . . .

    Alternatively:

    I prefer to use a counter object as a timer. Set the counter at 100 on creation, with a max value of 100. When the key is pressed AND the counter=100 then set the counter to 0 and do whatever else you need to do.

    You need a second line that says something like EVERY 1/100 of a second ADD 1 to the counter.

    Hope this helps you out.

  4. #4
    Clicker Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)iOS Export Module (Steam)

    Join Date
    Sep 2008
    Location
    Western Australia
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Toggle an in-game setting

    Thanks for the replies; I guessed I'd be having to create some sort of delay, but I thought I'd check first.

    The link was particularly helpful

  5. #5
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Toggle an in-game setting

    There is no need for delay. You could also do this in your case:

    Set Alt val MUTE to 1-Alt val MUTE
    Working as fast as I can on Fusion 3

  6. #6
    Clicker Fusion 2.5 Mac
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)iOS Export Module (Steam)

    Join Date
    Sep 2008
    Location
    Western Australia
    Posts
    256
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Toggle an in-game setting

    Quote Originally Posted by LB
    Set Alt val MUTE to 1-Alt val MUTE
    Perfect.

    (Kicks self! :cry

    Thanks LB

Similar Threads

  1. iOS Toggle Switch
    By JosephFTaylor in forum iOS Specific Example Files
    Replies: 3
    Last Post: 5th April 2013, 07:32 PM
  2. Setting up players/controllers for your game (single player)
    By colej_uk in forum XNA Specific Example Files
    Replies: 5
    Last Post: 26th March 2013, 01:21 PM
  3. Toggle Game Paused screen with image animation
    By Matriax in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 3rd January 2013, 03:24 PM
  4. Setting game Time
    By Rick in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 31st December 2006, 04:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •