[solved]oversensitive click on mouse

gruffman

  • *
  • Posts: 564
I'm new to stencyl and having a recurring issue with events happening when something is clicked on.

for example i just made a sound on/off button that does the obvious:) when i click on it you can hear the music stopping and starting repeatedly. its as if the event is being run every frame i guess, and multiple frames pass during the milliseconds my mouse button is down.

i'm guessing i need some sort of control mechanism to ensure the state can only be changed once every 2 seconds..?

« Last Edit: December 29, 2012, 12:10:00 pm by gruffman »
Now available for all Android Devices - Happy Face Concentration
My Games To Date
Find A Face / Hero Of Oda / Snakes And Ladders
Hungry Monkey available at fgl.com for Sponsorship
My site - Gruffgames.com

gruffman

  • *
  • Posts: 564
to put it another way, if i hold down the left mouse button on the actor, the music stops and resarts rapidly. i would rather the state changed once and couldnt change until the mouse is released, and another click made
Now available for all Android Devices - Happy Face Concentration
My Games To Date
Find A Face / Hero Of Oda / Snakes And Ladders
Hungry Monkey available at fgl.com for Sponsorship
My site - Gruffgames.com

NexusxAlpha

  • Posts: 157
I'm new to stencyl and having a recurring issue with events happening when something is clicked on.

for example i just made a sound on/off button that does the obvious:) when i click on it you can hear the music stopping and starting repeatedly. its as if the event is being run every frame i guess, and multiple frames pass during the milliseconds my mouse button is down.

i'm guessing i need some sort of control mechanism to ensure the state can only be changed once every 2 seconds..?

Hey there,

What you should do is set up a global variable (im guessing youll know how to do this) called "IsMuted?". Add a new event to the actor for the mute icon and say "if mouse is clicked on self then ismuted = true, save game, set volume to 0"

now to check if its muted or not

add another event to the actor and do "if ismuted = true and mouse is clicked on self then ismuted = false, save game, set volume to x"


gruffman

  • *
  • Posts: 564
Got it!



Took a while to get the logic perfectly right so that one button could be used as both the on and the off switch. Thanks :)
Now available for all Android Devices - Happy Face Concentration
My Games To Date
Find A Face / Hero Of Oda / Snakes And Ladders
Hungry Monkey available at fgl.com for Sponsorship
My site - Gruffgames.com