fivem-ts

a library to speed up the development of Fivem scripts and frameworks


Project maintained by Purpose-Dev Hosted on GitHub Pages — Theme by mattgraham

fivem-ts - Documentation v0.7.5Docs


fivem-ts - Documentation v0.7.5 / Client / Sprite

Class: Sprite

Represents a sprite, an object that can be drawn on the screen with a texture, position, size, rotation, and color.

Implements

Constructors

new Sprite()

new Sprite(textureDict, textureName, pos?, size?, heading?, color?): Sprite

Creates an instance of a Sprite.

Parameters

textureDict: string

The name of the texture dictionary.

textureName: string

The name of the texture.

pos?: Point

The position of the sprite on the screen.

size?: Size

The size of the sprite.

heading?: number = 0

The heading (rotation) of the sprite in degrees. Default is 0.

color?: Color

The color of the sprite. Default is white.

Returns

Sprite

Defined in

client/ui/Sprite.ts:26

Properties

color

color: Color

Implementation of

IDrawable.color

Defined in

client/ui/Sprite.ts:13


heading

heading: number

Defined in

client/ui/Sprite.ts:12


pos

pos: Point

Implementation of

IDrawable.pos

Defined in

client/ui/Sprite.ts:10


size

size: Size

Implementation of

IDrawable.size

Defined in

client/ui/Sprite.ts:11


textureName

textureName: string

Defined in

client/ui/Sprite.ts:9


visible

visible: boolean

Defined in

client/ui/Sprite.ts:14

Accessors

IsTextureDictionaryLoaded

get IsTextureDictionaryLoaded(): boolean

Checks if the texture dictionary is loaded.

Returns

boolean

True if the texture dictionary is loaded, otherwise false.

Defined in

client/ui/Sprite.ts:79


TextureDict

get TextureDict(): string

Gets the texture dictionary name.

set TextureDict(v): void

Sets the texture dictionary name and loads it if not already loaded.

Parameters

v: string

The texture dictionary name.

Returns

string

The texture dictionary name as a string.

Defined in

client/ui/Sprite.ts:60

Methods

draw()

Draws the sprite on the screen with either the specified or current attributes.

Param

The screen resolution to use for scaling or the texture dictionary name.

Param

The texture name.

Param

The position to draw the sprite at.

Param

The size to draw the sprite with.

Param

The heading (rotation) of the sprite in degrees.

Param

The color to draw the sprite with.

Param

Whether to load the texture if not already loaded.

Param

The screen resolution to use for scaling.

draw(resolution)

draw(resolution?): void

Draws the sprite on the screen.

Parameters

resolution?: Size

The screen resolution to use for scaling.

Returns

void

Param

The screen resolution to use for scaling or the texture dictionary name.

Param

The texture name.

Param

The position to draw the sprite at.

Param

The size to draw the sprite with.

Param

The heading (rotation) of the sprite in degrees.

Param

The color to draw the sprite with.

Param

Whether to load the texture if not already loaded.

Param

The screen resolution to use for scaling.

Implementation of

IDrawable.draw

Defined in

client/ui/Sprite.ts:87

draw(textureDictionary, textureName, pos, size, heading, color, loadTexture, resolution)

draw(textureDictionary?, textureName?, pos?, size?, heading?, color?, loadTexture?, resolution?): void

Draws the sprite on the screen with the specified parameters.

Parameters

textureDictionary?: string

The texture dictionary name.

textureName?: string

The texture name.

pos?: Point

The position to draw the sprite at.

size?: Size

The size to draw the sprite with.

heading?: number

The heading (rotation) of the sprite in degrees.

color?: Color

The color to draw the sprite with.

loadTexture?: boolean

Whether to load the texture if not already loaded.

resolution?: Size

The screen resolution to use for scaling.

Returns

void

Param

The screen resolution to use for scaling or the texture dictionary name.

Param

The texture name.

Param

The position to draw the sprite at.

Param

The size to draw the sprite with.

Param

The heading (rotation) of the sprite in degrees.

Param

The color to draw the sprite with.

Param

Whether to load the texture if not already loaded.

Param

The screen resolution to use for scaling.

Implementation of

IDrawable.draw

Defined in

client/ui/Sprite.ts:101


loadTextureDictionary()

loadTextureDictionary(): void

Loads the texture dictionary required for the sprite. This method will keep trying to load until the texture dictionary is loaded.

Returns

void

Defined in

client/ui/Sprite.ts:47