ID:1646914
 
Keywords: bars, health
(See the best response by MDC.)
Code:


Problem description:

So there are two problems i have.

In unity i can stretch a image(health bar) to decrease to the left. This made it so I only needed one image. Is there an equivalent so i dont need to make a bunch of icons?

2nd question. If im putting an object on the screen like a health bar how do you make it invisible to other players while also making it allow enabling easy icon state changes. I've done invisible stuff before, but with the knowledge i had it made changing icons kinda disgusting.
well i think i found the problem to my first question. it looks like i need to use matrics stuff. It looks pretty simple so just second question now, thanks
Best response
For the 2nd question, you might want to look up "image". You'd want to create the image, have it do what you want and then you can choose who to display it to.
You can use atom.transform to stretch the health bar.
var obj/health_bar = new
health_bar.icon = 'health bar.dmi'

var matrix/m = new
m.Scale(desired_width / original_width, 1)
// desired_width (in pixels) is how wide you want the bar to be
// original_width (in pixels) is the original width of the icon, e.g. 32

health_bar.transform = m


You'd also want to put the health bar in client.screen (aka the HUD) to make it visible to only the player.
// to place the health bar in the bottom-left of the screen
health_bar.screen_loc = "SOUTHWEST"

// and make sure it's over pretty much everything
health_bar.layer = 100

client.screen += health_bar