Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / how would i make a health bar

Author
Message
sskethan
15
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Oshawa, ON. Canada
Posted: 5th Jan 2013 00:18
I would like to create a bar below my player that increases and decreases.
This is the code i used to create it in DBP but i'm not sure how to do this in AGK. Is there a command to use like stretch?

xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 5th Jan 2013 00:26
Use one of these commands instead to stretch/scale sprites in AGK:

SetSpriteScale( iSpriteIndex, x, y )

SetSpriteSize( iSpriteIndex, width, height )

(You can also use SetSpriteScaleByOffset(...) if you need to scale from a previously set offset.)
sskethan
15
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Oshawa, ON. Canada
Posted: 5th Jan 2013 05:38
Thank you. Using setspritescale how would i decrease the health bar when there is a collision with an object. I was trying this but this seems to double the size of the sprite.

xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 5th Jan 2013 07:02 Edited at: 5th Jan 2013 07:32
The width and height values for SetSpriteScale are based on 1.0, not 100. So setspritescale ( 1000, 0.5, 1.0 ) will scale the sprite in half horizontally while retaining its original height. You can do the math as you please to ensure the percentage you need is on that 1.0 scale.

Or use SetSpriteSize() instead to use pixel values.
lilpissywilly
AGK Developer
13
Years of Service
User Offline
Joined: 10th Sep 2010
Location: Office Chair
Posted: 5th Jan 2013 14:31 Edited at: 5th Jan 2013 14:34
I guess I would do something like this, based on your example:



Well, I probably wouldn't do that, but something similar. It's an idea anyway

My hovercraft is full of eels
sskethan
15
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Oshawa, ON. Canada
Posted: 7th Jan 2013 05:04
Thank you both. Health bar is now working great. Everyone is so very helpful here. The game is coming along great.
http://www.youtube.com/watch?v=Oih6eJtExJY&feature=youtu.be
I'm having another problem now though. I have been able to figure out how to get the enemy to rotate and face the direction the player is.

But i'm having trouble working out how to make the enemy follow the player or move toward the player like a magnet.

Login to post a reply

Server time is: 2024-05-06 22:03:26
Your offset time is: 2024-05-06 22:03:26