Power Bar

Im trying to make a power bar that would rise and fall when an actor is touched and when the touch is released, for the actor to shoot something depending on the power. Anybody know how to make this
Thanks

Comments

  • colandercolander Member Posts: 1,610

    Google is your friend try doing a search like "power bar game salad" and you will find what you are looking for.

  • wcsd9739wcsd9739 Member Posts: 37

    There might be a better way of doing this, but at least for health bars I've just used a simple fix...

    First off, you'll want to make a behavior so that when the actor is touched it changes the power attribute... you can do this a couple of ways, one being to constrain it to a graph or something like that, but what I might try something like this...

     When Touch is Pressed:
          Constrain game.Power to self.Power
          When self.Power=0, Interpolate self.Power to 100 over 1 second
          When self.Power=100, Interpolate self.Power to 0 over 1 second
     When Touch is Released:
          Set game.Power to self.Power
    

    *N.B.: I used separate game and self attributes because the interpolate will complete even after release (at least it does on PC, although I think it's the same on Mac), so the game attribute can just capture where the self attribute currently is.

    So now that we've got the attribute itself working, now for the visualization...

    If the bar isnt just a simple image/color that can be stretched, you'll want to messing around the Graphics attribute, set something to Fixed (sorry, I'm on my phone right now, so I can't check :P). As for the actual growing and shrinking, on the power bar display actor, just put a Constrain self.Size.Height to [game.Power*#]. Replace that '#' with whatever number that will make the max power * # = max height of the power bar.

    However, doing this will cause your power bar to grow from its center instead of at the top like you might want. If you aren't fine with that, then you'll also need to add another behavior, something like "Constrain self.Position.Y to self.BarBottomY+self.Size.Height/2

    Well hope my lil attempt helps. Good luck with your project! :D

  • deeno deeno Member Posts: 10

    Thank you so much this was exactly what i was looking for.

  • zweg25zweg25 Member Posts: 738

    @colander said:
    Google is your friend try doing a search like "power bar game salad" and you will find what you are looking for.

    +1, the forums are already stacked with very similar problems

  • deeno deeno Member Posts: 10

    It works but the power won't depend on how far up the power bar is.Anyone know how to fix this?

  • jigglybeanjigglybean Member Posts: 1,584

    This is for a power meter but you can maybe get some help/idea on the math

    Like Balls? Then click here! We've 100 coming soon

Sign In or Register to comment.