Garry's Mod Wiki

DSprite

Description

A panel that draws a sprite on the player's HUD with the given IMaterial, Color and rotation.

A shortcut for this is CreateSprite().

View source

Parent

Derives methods, etc not listed on this page from DPanel.

Methods

table DSprite:GetColor()
Gets the color the sprite is using as a modifier.
Vector DSprite:GetHandle()
We advise against using this. It may be changed or removed in a future update. Returns the value set by DSprite:SetHandle
Gets the material the sprite is using.
Gets the 2D rotation angle of the sprite, in the plane of the screen.
DSprite:SetColor( table color )
Sets the color modifier for the sprite.
DSprite:SetHandle( Vector vec )
We advise against using this. It may be changed or removed in a future update. Seems to be an unused feature. Does nothing.
DSprite:SetMaterial( IMaterial material )
Sets the source material for the sprite.
DSprite:SetRotation( number ang )
Sets the 2D rotation angle of the sprite, in the plane of the screen.

Example

Creates a DSprite with the sent_ball material, and sets the color to cyan.

local sprite = vgui.Create("DSprite") sprite:SetMaterial(Material("sprites/sent_ball")) sprite:SetColor(Color(0, 255, 255)) sprite:Center() sprite:SetSize(200, 200)
Output: See Preview above.