Creating a cast bar

beckbbeckb Member Posts: 16
I'd like to have a cast bar show up at the same part of the screen every time a key is pressed. Is there a way to have it increase from zero to full on a certain timer? (E.g. 2-second cast, 3-second cast, etc.).

Many thanks.

Comments

  • beckbbeckb Member Posts: 16
    Oh, I would also like to make it so that the player must wait until the casting is finished before they can do anything else (i.e. - can't cast two spells at the same time)
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Here's a demo I made for you.

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

  • TheGabfatherTheGabfather Member Posts: 633
    edited April 2013
    Yes! You can use a Timer Behavior. You can tell the timer to execute specific behaviors after X sec.

    Create a custom Attribute that takes note if a spell has been cast. When a spell is cast, set that Attribute to "true." Next tell the Timer to set that Attribute to "false" after X sec.

    Now set all your spell Actors to do nothing when tapped whenever the custom Attribute is still "true."
  • beckbbeckb Member Posts: 16
    Here's a demo I made for you.
    Helpful as always tatiang, thank you. I have a question though as I looked through your demo and was a bit confused. Why change self.originalheight=self.size.height and self.originalY=self.position.y?

    I'm trying to create a horizontal cast bar where the left border is static (much like yours, where the bottom border of your life bar is static). So I'm trying to find a way to apply what's in your demo to my project. Thanks!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    The self.originalHeight and self.originalY attributes store the starting height and position of the actor so it can be used in a formula later in the rules.

    The reason for that is that GameSalad resizes actors while keeping their x/y values the same. So if you start to shrink a horizontal bar (rectangular actor), it will shrink from the sides instead of from only one side as you might expect and want. Therefore, to make it shrink from one side, we have to continually move it over towards the side we don't want to shrink. That's what the interpolate (or constrain) behaviors are for. For a horizontal bar, you would use self.size.width and self.position.X.

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

Sign In or Register to comment.