Health value and/or bar over character sprite

192 views
Skip to first unread message

Orthonormal

unread,
Jun 20, 2012, 11:41:15 AM6/20/12
to mel...@googlegroups.com
I have a variable, "var health = 100". How do I display its value on a sprite?

Do I have to use the draw function on the screen object? (http://www.melonjs.org/docs/symbols/me.ScreenObject.html)

Orthonormal

unread,
Jun 20, 2012, 11:44:12 AM6/20/12
to mel...@googlegroups.com
Or should I do it using a HUD object like in the tutorial? And set its location over the player sprite?

melonJS

unread,
Jun 21, 2012, 11:15:45 PM6/21/12
to mel...@googlegroups.com
Hi,
That's something we already discusses in a previous topic (if you want to look for it), and my recommendation would be to redefine the entity draw function of your entity and add the drawing of your health bar (either text, png, etc., using the given context parameter), and without forgetting to call your entity parent function when you are done :)

Orthonormal

unread,
Jun 23, 2012, 9:04:29 AM6/23/12
to mel...@googlegroups.com
Thanks for the clarification! :)
Reply all
Reply to author
Forward
0 new messages