GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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

KumkaniKumkani Posts: 28Member, PRO

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.

Comments

  • AdrenalineAdrenaline Posts: 523Member

    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 Posts: 28Member, PRO

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

  • tatiangtatiang Posts: 11,845Member, Sous Chef, PRO, Senior Sous-Chef
    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 Posts: 523Member

    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 Posts: 28Member, PRO

    REALLY appreciate the help! I will try this tomorrow!

  • KumkaniKumkani Posts: 28Member, PRO

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

Sign In or Register to comment.