Class View.DisplaySprite

Represents a display sprite.

Functions

DisplaySprite(objectID, index, pos, rot, scale, [color]) Create a DisplaySprite object.
DisplaySprite(pos, rot, scale, [color]) Create a DisplaySprite object with a video image.
DisplaySprite:GetObjectID() Get the object ID of the sprite sequence object used by the display sprite.
DisplaySprite:GetSpriteID() Get the sprite ID in the sprite sequence object used by the display sprite.
DisplaySprite:GetPosition() Get the display position of the display sprite in percent.
DisplaySprite:GetRotation() Get the rotation of the display sprite in degrees.
DisplaySprite:GetScale() Get the horizontal and vertical scale of the display sprite in percent.
DisplaySprite:GetColor() Get the color of the display sprite.
DisplaySprite:GetAnchors([alignMode], [scaleMode]) Get the anchors of the display sprite.
DisplaySprite:SetObjectID(objectID) Set the sprite sequence object ID used by the display sprite.
DisplaySprite:SetSpriteID(spriteID) Set the sprite ID in the sprite sequence object used by the display sprite.
DisplaySprite:SetPosition(position) Set the display position of the display sprite in percent.
DisplaySprite:SetRotation(rotation) Set the rotation of the display sprite in degrees.
DisplaySprite:SetScale(scale) Set the horizontal and vertical scale of the display sprite in percent.
DisplaySprite:SetColor(color) Set the color of the display sprite.
DisplaySprite:Draw([priority], [alignMode], [scaleMode], [blendMode]) Draw the display sprite in display space for the current frame.


Functions

DisplaySprite(objectID, index, pos, rot, scale, [color])
Create a DisplaySprite object.

Parameters:

  • objectID ObjID ID of the sprite sequence object.
  • index int Index of the sprite in the sequence.
  • pos Vec2 Display position in percent.
  • rot float Rotation in degrees.
  • scale Vec2 Horizontal and vertical scale in percent. Scaling is interpreted by the DisplaySpriteEnum.ScaleMode passed to the Draw() function call.
  • color Color Color. Default: Color(255, 255, 255).

Returns:

    DisplaySprite A new DisplaySprite object.
DisplaySprite(pos, rot, scale, [color])
Create a DisplaySprite object with a video image. Video should be played using View.PlayVideo function in a background mode. If no video is played, sprite will not show.

Parameters:

  • pos Vec2 Display position in percent.
  • rot float Rotation in degrees.
  • scale Vec2 Horizontal and vertical scale in percent. Scaling is interpreted by the DisplaySpriteEnum.ScaleMode passed to the Draw() function call.
  • color Color Color. Default: Color(255, 255, 255, 255) Optional.

Returns:

    DisplaySprite A new DisplaySprite object with attached video image.
DisplaySprite:GetObjectID()
Get the object ID of the sprite sequence object used by the display sprite.

Returns:

    ObjID Sprite sequence object ID.
DisplaySprite:GetSpriteID()
Get the sprite ID in the sprite sequence object used by the display sprite.

Returns:

    int Sprite ID in the sprite sequence object. Value -1 means that it is a background video, played using View.PlayVideo.
DisplaySprite:GetPosition()
Get the display position of the display sprite in percent.

Returns:

    Vec2 Display position in percent.
DisplaySprite:GetRotation()
Get the rotation of the display sprite in degrees.

Returns:

    float Rotation in degrees.
DisplaySprite:GetScale()
Get the horizontal and vertical scale of the display sprite in percent.

Returns:

    Vec2 Horizontal and vertical scale in percent.
DisplaySprite:GetColor()
Get the color of the display sprite.

Returns:

    Color Color.
DisplaySprite:GetAnchors([alignMode], [scaleMode])
Get the anchors of the display sprite. Anchors are the vertices of the display sprite, which can be used to position other objects relative to it.

Parameters:

  • alignMode AlignMode Alignment mode. Default: DisplaySpriteAlignMode.Center.
  • scaleMode ScaleMode Scaling mode. Default: DisplaySpriteScaleMode.Fit.

Returns:

    DisplayAnchors An object containing the anchor points of the display sprite.
    The object contains the following fields:
    - TOP_LEFT
    - TOP_CENTER
    - TOP_RIGHT
    - CENTER_LEFT
    - CENTER
    - CENTER_RIGHT
    - BOTTOM_RIGHT
    - BOTTOM_CENTER
    - BOTTOM_LEFT

Usage:

    local objID = Objects.ObjID.ID_DEFAULT_SPRITES
    local sprite = View.DisplaySprite(objID, 0, Vec2(50, 50), 0, Vec2(20, 20))
    local anchors = sprite:GetAnchors()
    print("Center anchor: " .. tostring(anchors.CENTER)) -- Output: Center anchor: Vec2(50.0, 50.0)
DisplaySprite:SetObjectID(objectID)
Set the sprite sequence object ID used by the display sprite.

Parameters:

  • objectID ObjID New sprite sequence object ID.
DisplaySprite:SetSpriteID(spriteID)
Set the sprite ID in the sprite sequence object used by the display sprite.

Parameters:

  • spriteID int New sprite ID in the sprite sequence object.
DisplaySprite:SetPosition(position)
Set the display position of the display sprite in percent.

Parameters:

  • position Vec2 New display position in percent.
DisplaySprite:SetRotation(rotation)
Set the rotation of the display sprite in degrees.

Parameters:

  • rotation float New rotation in degrees.
DisplaySprite:SetScale(scale)
Set the horizontal and vertical scale of the display sprite in percent.

Parameters:

  • scale Vec2 New horizontal and vertical scale in percent.
DisplaySprite:SetColor(color)
Set the color of the display sprite.

Parameters:

DisplaySprite:Draw([priority], [alignMode], [scaleMode], [blendMode])
Draw the display sprite in display space for the current frame.

Parameters:

  • priority int Draw priority. Can be thought of as a layer, with higher values having precedence. Negative values will draw sprite above strings, while positive values will draw it under. Default: 0.
  • alignMode AlignMode Align mode interpreting an offset from the sprite's position. Default: View.AlignMode.CENTER.
  • scaleMode ScaleMode Scale mode interpreting the display sprite's horizontal and vertical scale. Default: View.ScaleMode.FIT.
  • blendMode BlendID Blend mode. Default: Effects.BlendID.ALPHABLEND.
generated by TEN-LDoc (a fork of LDoc 1.4.6)