how to create a controller for the volume?

venon_itvenon_it Member, PRO Posts: 594
edited November -1 in Working with GS (Mac)
Hi,
i want to create a controller for volume...

know how to do?

Thankkssss

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    I made slider controls...

    click on options from the main menu:

    http://gamesalad.com/game/play/30122
  • venon_itvenon_it Member, PRO Posts: 594
    yesssss, firemaplegames ,

    What are the settings fot it??

    Thanksssss
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Hey,

    Ok, here you go:

    You need a global game attribute (real) called musicVolume.

    In the slider, you need a boolean attribute called "dragging".
    You also need 2 attributes (real) called leftLimit and rightLimit.
    (those are the left and right boundaries of the slider.)

    You need 5 separate rules in the slider:

    1. When you click on the slider, change "dragging" to TRUE.

    2. When you release the mouse, change "dragging" to FALSE.

    3. When "clicked" = TRUE
    self.PositionX = Mouse.PositionX

    4. When self.PositionX <= leftLimit
    self.PositionX = leftLimit

    5. When self.PositionX >= rightLimit
    self.PositionX = rightLimit

    Finally, you need to use Constrain Attribute:
    game.musicVolume = floor( self.Position.X - self.leftLimit )/(self.rightLimit - self.leftLimit)

    And, if you want live feedback:

    Constrain Attribute:
    game.Audio.Volume To: game.musicVolume

    Hope this helps!
  • venon_itvenon_it Member, PRO Posts: 594
    hi,

    thankssss, i try but don't function... i create a GS and add here : http://gamesalad.com/game/play/30189
    you can download it and if you want modify the example?
    could be helpful to many users

    Thanksss a lot
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Hey,

    I created a demo for you. It's fully commented, feel free to use it for whatever you need.

    http://gamesalad.com/game/play/30207

    Best,
    Joe
Sign In or Register to comment.