Button sticks when I press just inside and move finger out

dogfishdogfish Member Posts: 12
edited December 2011 in Working with GS (Mac)
My buttons are designed so that the action associated with it doesn't happen until I release. (I have two images; "button normal" and "button depressed". That way if you press it but slide your finger off, the button will change back to being up, without the action happening. It works fine except when I press just on the edge and barely slide off, the button gets stuck in the depressed position. I turn a boolean trigger on when pressed, to avoid going into infinite loops. But I don't think I'm using the "touch pressed/released" stuff right....or MAYBE it is just an internal timer issue? If it can't be resolved, I may change it so the action happens when I press down, because I don't want it to look sloppy.

Thanks!
dF

Comments

  • dogfishdogfish Member Posts: 12
    In the button release rules, which "actor receives action" commands do I use to distinguish between releasing inside the button (with the intention of the button working) and sliding from inside to outside the button (so that the button goes to normal but no action happens)?

    I just think I tried to embed something properly and didn't quite understand how each one worked (since my code failed).
  • MotherHooseMotherHoose Member Posts: 2,456
    if your button graphic is a round image … remember that the actual image is a square and the transparent pixels in the corners are still affected by the touch/mouse events.

    you could create a separate smaller square transparent image to top the button and have it respond to the touch/mouse rules.

    MH
  • dogfishdogfish Member Posts: 12
    Sorry but I am still missing something.
    See how in GameSalad, the green preview button darkens when you press the mouse button down, but the preview doesn't start unless you release? AND, if you press the mouse button down, but -slide- the mouse off of the button, the button goes back to normal and the preview doesn't activate?
    I want all my buttons to do that. Yet no matter what I try I either get the button to activate when I slide off, or I go into endless loops, etc.
  • dogfishdogfish Member Posts: 12
    I should also add that I have some buttons like a mute button which means releasing the button changes the image depending on whether Sound is on/off. That might be compounding my problem.
  • MotherHooseMotherHoose Member Posts: 2,456
    @dogfish … you can do that when you do development in Xcode ;)

    in GS you have to play around with the options for mouse button and mouse position

    in GS: File:new project … create 4 actors … on each Actor create a Rule each having one of the 4 mouse conditions
    put a simple action/event in those rules: EX: changeAttribute [exp] self.color.Red To: 0
    drag all four actors to the scene and preview what happens when the mouse is active

    in other words learn to play in a sandbox … rather than attempt new things in your working Project
    do new actions events that you aren't sure will work, or to figure out the best way to make things work, in a sandbox project.
    less frustrating, more effective learning, and wont corrupt your good project.

    MH
  • dogfishdogfish Member Posts: 12
    edited December 2011
    I figured it out. Thanks for your patience and advice.

    How to make a button depress and only do an action when released within the button (a mute toggle, in this example):

    Rule: When touched is released,
    **Rule: When attribute game.sound = 1
    -----------Set Image to Soundoff
    -----------Change Attribute game.sound to 0
    **Otherwise:
    -----------Set Image to Soundon
    -----------Change Attribute game.sound to 1
    ----------------------------------------------
    Rule: When touch is pressed AND
    Mouse position is inside
    ---------Set Image to Soundpressed
    Otherwise:
    **Rule: When game.sound = 0
    ------------Set Image to Soundoff
    **Otherwise:
    ------------Set Image to Soundon
Sign In or Register to comment.