how to make actor return to original size when mouse is released??

KumkaniKumkani Member, PRO Posts: 28

Ok So I can make the actor grow when I click, but I can't figure out how to make it return to normal. I've tried using the else tab, I tried making a new rule (the new rule makes the actor disappear)

what i did to make it grow is I used change attribute ( self.size ) to (self.size.width) +100 then repeated with heigt, works GREAT, but I can't do the reverse.


  • AdrenalineAdrenaline Member Posts: 523

    You can store the original value in an attribute before you change the size. And then set the width and height to that attribute later.

  • KumkaniKumkani Member, PRO Posts: 28

    Thanks, is there a tutorial for this? I'm BRAND spanking new to this, it's fun but I'm really nooby here!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,927
    edited April 2014

    Nope, no tutorial but it's simple enough to just explain:

    Create two real attributes called self.startWidth and self.startHeight (what you call them doesn't matter but they should be of type Real).

    Add two behaviors to the top of the actor's rule list (but not inside of a rule):
    Change attribute self.startWidth to self.size.Width Change attribute self.startHeight to self.size.Height

    When you want to return the actor to it's original size, assuming you have a rule that gets triggered for that, do this:

    Change attribute self.size.Width to self.startWidth Change attribute self.size.Height to self.startHeight

    If you want the change to be gradual instead of instant, you'd use the Intepolate behavior to interpolate the value of self.size.Width to self.startWidth and the same for self.size.Height.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • AdrenalineAdrenaline Member Posts: 523

    No problem! I don't know of a tutorial that does exactly this, but you'll see the practice of saving attributes in almost every tutorial out there.

    Start by creating 2 new attributes: origW, origH

    Add a change attribute behavior to your actor that changes origW to the actor's width, and origH to the actor's height.

    Then you can do anything to the size and when it comes time to reset it, just change the actor's width to origW and the actor's height to origH.

    Hope that makes sense.

  • KumkaniKumkani Member, PRO Posts: 28

    REALLY appreciate the help! I will try this tomorrow!

  • KumkaniKumkani Member, PRO Posts: 28

    SUCCESS!!!!!! Thanks so much! this is brilliant!

Sign In or Register to comment.