Game Maker Studio: How to Create Lives & Healthbar for Player & Boss.
Visit my anime and game site: http://mcanime1.wixsite.com/mcanime
GMX File: https://goo.gl/SYvCQp
Note: Game Maker will only allow you to create one Lives and one Health bar, if you try to make more, when you hit the player or the boss using weapon, while having two Health bars for both characters or have two Lives you will both lose health, because relative is checked, if you don't check relative, then you will not lose Lives or Health. Got to make sure to use two different health's for characters.
Bosshp:
Events:
Step
Actions:
If health is smaller than 1
Start of a block
Set the health to 0
Else
End the game or you can create a room for End the Game.
End of a block
Events:
Game Start
Actions:
Set the health to 100
Events:
Draw GUI
Actions:
Draw the health bar
x1: view_xview+2800
y1: view_yview+170
x2: view_xview+2540
y2: view_yview+70
Back color: Red
Bar color: Yellow
Playerlives:
Events:
Create
Actions:
Set lives relative to 5
Events:
No More Lives
Actions: End the game or set a room up for end game
Events:
Draw GUI
Actions:
Draw the lives as image
x: 170
y: 100
Note: May need to adjust x and y numbers when dealing with PC or Android to get hearts or your image in the correct location on screen; also resize image of hearts or whatever image you are going to use for the health. Resize in Photoshop or a different program, if you try to resize in Game Maker, it will resize, but on screen it will not look smaller or bigger, it will be the same size.
Note: Also leave space around heart image or your image you use, this will determine the spacing around heart image for each heart image or your image your using. You don't want them overlapping one another, so leave some space around image.
Boss:
Events:
Playerweapon collison
Actions:
Change instance into from bosstopper to hittopperboss
perform event: yes
Set the health relative to -25
Destory the instance: Other
Events:
Create
Actions:
Set Alarm 0 to room_speed*3
Events:
Alarm 0
Actions:
Set Alarm 0 to room_speed*3
Change instance from boss to boss fire, perform event: yes
Player:
Events:
bossweapon collision
Actions:
Change instance into from playertopper to playerhittopper
perform event: yes
Set lives relative to -1
Destroy the instance: Other
Events:
Left Pressed
Change player to playerfire, perform event: yes
Blocker:
Be sure its not visible and make sure its checked as solid