Jump to content

how do I add images to a hud? *RESOLVED*


Imchasinyou
 Share

Recommended Posts

Ive been trying to get a simple hud at the bottom of the screen and mostly successful but In trying to get an image into it I keep getting error after error. Any help would be awesome and might help me learn something hopefully. Here is the bit of the code where I need help.

When calling the heart image, i either get a nil value or a different of several errors.

 

	 if self.health>0 then
context:SetColor(0,0,1,0.5)
context:DrawRect(0,1003,1920,40)
context:SetColor(1,0,0,1)
 context:DrawText("Score: "..self.score, context:GetWidth()-150,context:GetHeight()-25)
context:DrawImage(self.image.hand, 1700, 1005) --replace image with different
 context:DrawText("Health: "..self.health.."/"..self.maxHealth,context:GetWidth()-1850,context:GetHeight()-25)
self.texture = Texture:Load("Materials/Hud/heart.tex")
context:DrawImage(self.image.heart) (0,0,10,1005) --replace image with heart image
			 if self.canUse==true and self.carryingEntity == nil then
					 local pickUpX = math.floor((context:GetWidth() - self.image.hand:GetWidth()))/2
					 local pickUpY = math.floor((context:GetHeight() - self.image.hand:GetHeight()))/2
					 context:SetBlendMode(Blend.Alpha)
					 context:DrawImage(self.image.hand, pickUpX, pickUpY)

Asus sabertooth 990FX, AMD FX 9590 , Windows 7 Home Premium 64 Bit, 4 HDD's Western Digital Caviar Black set in Raid 0, 16 GB Crucial Ballistix Elite, Asus Radeon R9 270 X 4GB, Corsair CM750M,

Link to comment
Share on other sites

If i call any of the stock textures, they work such as crosshair. I just cant figure out why mine wont work.

 

Nailed it! After looking over the rest of the script, I wasnt calling it in the start function to load the texture.

 

self.image.heart = Texture:Load("Materials/HUD/heart.tex")

Asus sabertooth 990FX, AMD FX 9590 , Windows 7 Home Premium 64 Bit, 4 HDD's Western Digital Caviar Black set in Raid 0, 16 GB Crucial Ballistix Elite, Asus Radeon R9 270 X 4GB, Corsair CM750M,

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...