Animate button

patapplepatapple Member Posts: 873
edited February 2012 in Working with GS (Mac)
hi guys,

i need to animate a few buttons, but I do not know from where to begin??? any animation goes to me well!! do you have any idea or template?? ;)

thanks

Comments

  • simo103simo103 Member, PRO Posts: 1,331
    edited February 2012
    @patapple ... I usually go for adding a rule to my buttons 'when touch is pressed then change attribute self.size.width to (a number about 10% bigger than normal) and do the same for Height.

    Also put change attributes in the Otherwise part of the rule to set the width and height back to normal. I also put a play sound in the rule ... so it now gives a sound response and the user can see something happened when you touch the button. If the button changes to a new scene, or brings up a level or menu or something I usually add a timer in the touch rule to delay that happening by a 0.3 secs or something so the button 'grows' and 'shrinks' before loading a new page.
  • patapplepatapple Member Posts: 873
    Yes, i have an animation and a sound when the button is pressed, but now i want to animate also when the button is in "stop"....do you have understood what i intend? thanks
  • simo103simo103 Member, PRO Posts: 1,331
    @patapple you could put an animate behaviour in the otherwise part of the rule?!?
  • patapplepatapple Member Posts: 873
    no, how can i create an effect enlarge and make small (loop)?? sorry i don't speak english very well :(
  • simo103simo103 Member, PRO Posts: 1,331
    @patapple ... I guess you could wrap your enlarge and make small behaviours in a timer and set it to Every x.xx secs that way it would loop over and over.
  • CloudsClouds Member Posts: 1,599
    @patapple

    ” i want to animate also when the button is in "stop"."

    Place this animation inside the 'otherwise' section of your rule.
  • Rob2Rob2 Member Posts: 2,402
    edited February 2012
    This is a method for a simple loop that maybe more efficient than a timer.

    self.flash = 0 and the length of the loop is determined by the value after the % so in this case it is 0.5 of a second
    (less than than about 0.12 and it fails)

    image

    and remember self.Time has to be selected NOT typed in

    image
  • MotherHooseMotherHoose Member Posts: 2,456
    1. on button an Attribute index type : name Stop leave 0

    on button:
    2. Rule: when
    Attribute: self.Stop = 0
    ---Rule: when (this is nested in self.Stop rule)
    ---Event: touch is pressed
    ----play sound
    ----do animation
    ---Rule: when (this is nested in self.Stop rule)
    ---Attribute: self.Image = (last imageName in animation)
    ----changeAttribute: self.Stop To: 1
    Otherwise:
    -do the stopAnimation

    @};- MH
  • patapplepatapple Member Posts: 873
    edited February 2012
    but to do this animation i need all the png files and use the animate behavior??? i don't want that...i thought i can do that whit the interpolate attribute(width and height)??

    edit: this is an example! is that possible to do in GS?? (the movement)
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    @patapple

    image

    . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

    Constrain width to . . . . 20*cos( self.Time *100)+100
    Constrain height to . . . . 20*cos(self.Time*100)+100

    AAA*cos(self.Time*BBB)+CCC

    AAA = the amount of change . . . so . . . . 50 = 25 pixels bigger - then 25 pixels smaller - then 25 pixels bigger . . . etc etc
    BBB = speed of change
    CCC = size of object . . . . so if CCC is 100 and AAA is 50 then size = 125 then 75 then 125 then 75 then 125 . . . . etc etc
  • patapplepatapple Member Posts: 873
    WOW...it works...but there is a little problem: i have a rectangle button and the animation transform it to a squared! why that??
    THANKS
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    Flashing colour change:

    image


    '200' = speed of the flashing.
  • CloudsClouds Member Posts: 1,599
    edited February 2012
    @patapple

    "i have a rectangle button and the animation transform it to a squared!"

    Because CCC is the size of the object . . . take a look at what is happening, it's simple and all explained for you . . . I am not going to give you any more clues, you need the exercise ! Lol. ;)
  • patapplepatapple Member Posts: 873
    HAHAHA lol...yeah it works I fix the "CCC" of the two constrain attribute and it's amazing!!! thank you very much
Sign In or Register to comment.