Astrath:createImage

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

DxImage:new

Template:FuncDef

Description: Creates a new DX-based image element. Images can be attached to parent elements, support transparency, custom styles, and optional parent-relative positioning. Each image instance is automatically registered in the DX library.

Parameters:

  • path (string) – Path to the image file. Must exist.
  • posX, posY (float) – Position on screen.
  • width, height (float) – Size of the image.
  • parent (element) – Parent DX element to attach this image to (optional).
  • relative (boolean) – Position relative to parent (optional).

Returns:

Returns the newly created DxImage element.

Methods:

Method Description
Ath:destroy() Destroys the image element and all its child elements.
Ath:setVisible(boolean) Shows or hides the image.
Ath:setEnabled(boolean) Enables or disables the image for interaction.
Ath:setAlpha(number) Sets the image transparency (0–255).

Example:

local myImage = DxImage:new("images/logo.png", 100, 100, 200, 150)

myImage:setVisible(true)
myImage:setAlpha(200)
myImage:setPath("images/new_logo.png")
myImage:draw()

See also: