How do I make an Impulse Bar

0 favourites
  • 5 posts
From the Asset Store
Health, Weapon & Rage Bars for your Games. Easy to use & Customize.
  • Hello again Constructors! once again I need some help from the pros...

    I have been developing a game which uses a catapult system, specifically the power of the shot is equal to the distance between the touch (cursor) position and the ball position.

    The thing is that I have a radial power bar with 24 frames that should display the force of the shot. The idea is to link all together, if the cursor gets closer then the radial bar should be something around the 3rd or 6th frame.

    There should be a limitation on the force as well, because the max force will be when the radial reaches the 24th frame, even if the player points far in the distance the max force should stay at the same value for the 24th frame.

    I'm not sure if I explained it in a way it doesn't look complicated, I don't have a CAPX due this problem is quite abstract for me right now. Though questions are more than welcome to clarify the information for those helping minds

    Thanks in advance!

  • If you have a maximum value and a minimum value for the power it would be quite easy..

    Should be something like this:

    set Variable PowerOfShot to : clamp(distance(touch.x,touch.y,ball.x,ball.y),0,maximum)

    radial powerball set frame to : round(24*(PowerOfShot/maximum))

  • Hi Stain, thanks for your fast response!

    Sorry but I still don`t get it, part of my brain is fried right now. Can you explain it once again, please?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi Stain, thanks for your fast response!

    Sorry but I still don`t get it, part of my brain is fried right now. Can you explain it once again, please?

    That would be quite useless, for the explanation would be the same..

    the clamp expression keeps the value of the variable PowerOfShot between a maximum and a minimum..

    by dividing the variable PowerOfShot with the maximum power you get a number between 0 and 1, when you multiply this by 24 you get a number between 0 and 24, by rounding it it will be an integer instead of a float and the frame can be set..

  • Sorry for the delay on my post. After cooling my head down I could understand what you said and worked like a charm, thanks a lot!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)