Fangames > Programming Questions
Invincibility Frames
lawatson:
Make a sprite for the health bar which is 1 pixel, and then draw it with the length of the maximum length / max HP * HP.
LoneTree_tv:
How do you change the length of the sprite?
lawatson:
image_xscale = x
it's multiplicative, so if you choose 1, it'll show the sprite, if you choose 2, it'll double the length, -1 will reverse the sprite, etc.
EDIT: Or actually, you'd probably rather just wanna put in the draw event:
draw_sprite_ext(spr_healthbar,0,x,y,image_xscale,1,0,c_white,1)
Replace the variables with whatever.
LoneTree_tv:
Alright, I tried using the draw event, which I've never used before, and ran into some problems
I only wrote this:
draw_sprite(HPBar,0,10,10)
and neither the sprite nor the boss appears.
also, just now, i tried
hpbar=draw_sprite(HPBar,0,10,10);
hpbar.image_xscale=500/20*hp
the boss and hp bar did not show, and the players sprite got stretched instead.
EDIT: Oops, didn't see your edit. Tried it, and it still didn't work. what should I put for the image scaling if the max hp is 20 and I want the length to be 500? I think the fact that I put "500/20*hp" is what screwed everything up.
EDIT2: Wow, I'm incredibly stupid. I replaced spr_healthbar with my sprite name, and that fixed it. But the boss still doesn't seem to want to exist. By that I mean it's invisible. It's still shootable if you can guess where he is.
EDIT3: Once again, I'm terrible. I just put in draw_self(); before the other line and everything worked perfectly.
lawatson:
Yeah, maybe I should have also said that you should put in draw_self() when using the draw event, but otherwise, there you go!
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version