GameMaker: Studio

GameMaker: Studio

View Stats:
Removing "Draw" sprite? (Solved)
I'm currently using Game Maker 8.1, which is, apparently, not here on Steam. I am trying to make a RPG-like game, and I have a problem.
When I hit a slime, the HP bar shows, as expected. Thing is, it doesn't disappear! Even if the slime is destroyed, the Enemy Bar is still on the HUD. Is there a way to make that bar invisible or something, without having to destroy the Control object? If I do, the HP and MP bars will be removed too
Last edited by Albcatmastercat; Oct 4, 2015 @ 7:20pm
< >
Showing 1-15 of 15 comments
Thew Oct 3, 2015 @ 5:41pm 
Make the draw contingent on a variable.
if (display_health){ //draw hp bar }
Albcatmastercat Oct 4, 2015 @ 11:15am 
Originally posted by Thew:
Make the draw contingent on a variable.
if (display_health){ //draw hp bar }
I tried doing that. As expected, the bar shows up once the sword hits said slime, but it stays there forever. What can I do to Fix it? (It doesn't look right, having an empty hp bar below the Char's HP and MP bars)
Thew Oct 4, 2015 @ 1:35pm 
You have a controller object that is handling the drawing of the health bar, if I'm reading right.

Make a variable called "display_health" and set it to false, then put the code in the draw event as I demonstrated above. When you want the object to display a health bar, set the variable to true and at the same time set an alarm for the length of time you want the bar to stay there.

In that alarm event, set the display_health variable back to false.
Albcatmastercat Oct 4, 2015 @ 3:46pm 
Originally posted by Thew:
You have a controller object that is handling the drawing of the health bar, if I'm reading right.

Make a variable called "display_health" and set it to false, then put the code in the draw event as I demonstrated above. When you want the object to display a health bar, set the variable to true and at the same time set an alarm for the length of time you want the bar to stay there.

In that alarm event, set the display_health variable back to false.
If I understand correctly, I already did that. Thing is it never goes away, even if the thing is set to false
Thew Oct 4, 2015 @ 5:19pm 
That's really strange. Can you post some of your code?
Albcatmastercat Oct 4, 2015 @ 5:58pm 
On the draw event of the Control object:
if global.FocusHPMAX>0
{
draw_sprite(Spr_EnemyHP,((global.FocusHP)/(global.FocusHPMAX)*100),view_xview+8,view_yview+68)
}
the Focus variables are obtained on the collision with the sword, on the slime; Each slime has a Creation Code with their stats, and one of the lines includes "global.FocusHP=EnemyHP", and so on. The bar never disappears, not even when said slime dies.
Daynar Oct 4, 2015 @ 6:18pm 
I feel kinda bad buting in, but it looks like you're checking HPMAX and not HP.
if global.FocusHPMAX>0 { draw_sprite(Spr_EnemyHP,((global.FocusHP)/(global.FocusHPMAX)*100),view_xview+8,view_yview+68) }
Last edited by Daynar; Oct 4, 2015 @ 6:19pm
Thew Oct 4, 2015 @ 6:21pm 
That global must not be getting set to 0 or below (possibly because the enemy is destroyed before it gets set). Do a show_debug_message(global.FocusHPMAX) in the controller's step or draw event to get a frame by frame read out.

EDIT: Ahah, Daynar is correct on that. I didn't even notice there were two globals.
Last edited by Thew; Oct 4, 2015 @ 6:22pm
Albcatmastercat Oct 4, 2015 @ 7:13pm 
I am going to try checking the other variable then; You guys will sure be credited.
Albcatmastercat Oct 4, 2015 @ 7:16pm 
Thanks a lot on that. It worked perfectly! On a side note, there's another thing that is bugging me.. How can I make a single sprite have several animations in it? I tried googling that and the only solution has been taken down from mediafire...
Thew Oct 4, 2015 @ 8:53pm 
You could do that by creating your own animation scheme (where you manually select the image_index in whatever order you needed), but it's much easier just to have seperate sprites for each animation. For example: spr_player_idle, spr_player_run, spr_player_jump, etc.

In the object, you'll set the sprite_index to whichever sprite you want to use at the time (also remember to set image_index to 0 so the animation will start on the first frame).
Albcatmastercat Oct 5, 2015 @ 11:59am 
Originally posted by Thew:
You could do that by creating your own animation scheme (where you manually select the image_index in whatever order you needed), but it's much easier just to have seperate sprites for each animation. For example: spr_player_idle, spr_player_run, spr_player_jump, etc.

In the object, you'll set the sprite_index to whichever sprite you want to use at the time (also remember to set image_index to 0 so the animation will start on the first frame).
Wouldn't that consume a tiny bit more memory? I want to make it as little resource-heavy as possible; Is there a way?
Thew Oct 5, 2015 @ 12:11pm 
It'll take almost exactly the same amount of memory. Gamemaker smartly incorporates all of your sprites into large texture pages, so it's very likely that your sprites will all end up on the same texture, regardless of having different names.

But, like I said, you CAN put all of the animations in one sprite if you want. Timing the animations will be really annoying though, so I highly recommend you just separate them.

Also, separating them will allow the animations to have different collision masks. So, for example, crouching can have smaller box than standing up.
Daynar Oct 5, 2015 @ 3:16pm 
Thew is correct, when I started I tended to put all animations in one sprite and it just makes everything more complicated and works awkwardly. You can save some space by limiting sprites to only what cannot be done in code. stretching rotation colorizing are (image_xscale,image_angle,image_blend) are all ways you can save memory. Also note that you only need sprites for one direction as image_xscale = -1 will flip it to face the other direction. A note here though, if you are micro adjusting things every frame it might just be better to do it in the sprite and make everything easier to work with.
Albcatmastercat Oct 5, 2015 @ 6:15pm 
that's good to know; I won't need to learn any new coding for that then :D Thanks again
< >
Showing 1-15 of 15 comments
Per page: 1530 50

Date Posted: Oct 3, 2015 @ 2:01pm
Posts: 15