An extension of PIXI.Mesh which emulate a PIXI.Sprite with a specific shader.

Param: texture

Texture bound to this sprite mesh.

Param: shaderClass

Shader class used by this sprite mesh.

Hierarchy (view full)

Properties

indices: Uint16Array

The indices of the geometry.

The shader bound to this mesh.

vertexData: Float32Array

This is used to store the vertex data of the sprite (basically a quad).

uvs: Float32Array

This is used to store the uvs data of the sprite, assigned at the same time as the vertexData in calculateVertices().

_texture: Texture

The texture that the sprite is using.

_anchor: ObservablePoint

The anchor point defines the normalized coordinates in the texture that map to the position of this sprite.

By default, this is (0,0) (or texture.defaultAnchor if you have modified that), which means the position (x,y) of this Sprite will be the top-left corner.

Note: Updating texture.defaultAnchor after constructing a Sprite does not update its anchor.

https://docs.cocos2d-x.org/cocos2d-x/en/sprites/manipulation.html

_batchData: {
    _tintRGB: number;
    _texture: Texture;
    indices: number[];
    uvs: number[];
    blendMode: BLEND_MODES;
    vertexData: number[];
    worldAlpha: number;
} = ...

Snapshot of some parameters of this display object to render in batched mode.

Type declaration

  • _tintRGB: number
  • _texture: Texture
  • indices: number[]
  • uvs: number[]
  • blendMode: BLEND_MODES
  • vertexData: number[]
  • worldAlpha: number
_width: number = 0

The width of the sprite (this is initially set by the texture).

_height: number = 0

The height of the sprite (this is initially set by the texture)

_textureID: number = -1

The texture ID.

_cachedTint: [red: number, green: number, blue: number, alpha: number] = ...

Cached tint value so we can tell when the tint is changed.

_textureTrimmedID: number = -1

The texture trimmed ID.

vertexTrimmedData: Float32Array = null

This is used to calculate the bounds of the object IF it is a trimmed sprite.

_tintColor: Color = ...

The tint applied to the sprite. This is a hex value. A value of 0xFFFFFF will remove any tint effect.

_tintRGB: number = 0xFFFFFF

The tint applied to the sprite. This is a RGB value. A value of 0xFFFFFF will remove any tint effect.

_textureUvs: any = null

An instance of a texture uvs used for padded SpriteMesh. Instanced only when padding becomes non-zero.

_tintAlphaDirty: boolean = true

Used to track a tint or alpha change to execute a recomputation of _cachedTint.

_paddingX: number
_paddingY: number
#geometry: Geometry = ...

Geometry bound to this SpriteMesh.

_transformID: number = -1

The transform ID.

_transformTrimmedID: number = -1

The transform ID.

#state: State = ...

The PIXI.State of this SpriteMesh.

#TEMP_RECT: Rectangle = ...

A temporary reusable rect.

#TEMP_POINT: Point = ...

A temporary reusable point.

Accessors

  • get texture(): Texture
  • The texture that the sprite is using.

    Returns Texture

  • get paddingX(): number
  • The x padding in pixels (must be a non-negative value.)

    Returns number

  • get paddingY(): number
  • They y padding in pixels (must be a non-negative value.)

    Returns number

  • get padding(): number
  • The maximum x/y padding in pixels (must be a non-negative value.)

    Returns number

  • set blendMode(value): void
  • The blend mode applied to the SpriteMesh.

    Parameters

    • value: any

    Returns void

    Default Value

    PIXI.BLEND_MODES.NORMAL
    
  • set roundPixels(value): void
  • If true PixiJS will Math.round() x/y values when rendering, stopping pixel interpolation. Advantages can include sharper image quality (like text) and faster rendering on canvas. The main disadvantage is movement of objects may appear less smooth. To set the global default, change PIXI.settings.ROUND_PIXELS

    Parameters

    • value: any

    Returns void

    Default Value

    PIXI.settings.ROUND_PIXELS
    
  • get alphaMode(): ALPHA_MODES
  • Used to force an alpha mode on this sprite mesh. If this property is non null, this value will replace the texture alphaMode when computing color channels. Affects how tint, worldAlpha and alpha are computed each others.

    Returns ALPHA_MODES

  • get pluginName(): string
  • Returns the SpriteMesh associated batch plugin. By default the returned plugin is that of the associated shader. If a plugin is forced, it will returns the forced plugin.

    Returns string

  • get width(): number
  • Returns number

  • get height(): number
  • Returns number

  • get anchor(): ObservablePoint
  • The anchor sets the origin point of the sprite. The default value is taken from the PIXI.Texture|Texture and passed to the constructor.

    The default is (0,0), this means the sprite's origin is the top left.

    Setting the anchor to (0.5,0.5) means the sprite's origin is centered.

    Setting the anchor to (1,1) would mean the sprite's origin point will be the bottom right corner.

    If you pass only single parameter, it will set both x and y to the same value as shown in the example below.

    Returns ObservablePoint

  • get tint(): number
  • The tint applied to the sprite. This is a hex value.

    A value of 0xFFFFFF will remove any tint effect.

    Returns number

    Default Value

    0xFFFFFF
    
  • get sourceElement(): HTMLImageElement | HTMLVideoElement
  • The HTML source element for this SpriteMesh texture.

    Returns HTMLImageElement | HTMLVideoElement

  • get isVideo(): boolean
  • Is this SpriteMesh rendering a video texture?

    Returns boolean

Methods

  • Update uvs and push vertices and uv buffers on GPU if necessary.

    Returns void

  • Initialize shader based on the shader class type.

    Parameters

    Returns void

  • Returns void

  • Calculates worldTransform * vertices, store it in vertexData.

    Returns void

  • Calculates worldTransform * vertices for a non texture with a trim. store it in vertexTrimmedData.

    This is used to ensure that the true width and height of a trimmed texture is respected.

    Returns void

  • Parameters

    • renderer: any

    Returns void

  • Returns void

  • Parameters

    • rect: any

    Returns any

  • Parameters

    • point: any

    Returns boolean

  • Parameters

    • options: any

    Returns void

  • Protected

    When the texture is updated, this event will fire to update the scale and frame.

    Returns void

  • Protected

    Called when the anchor position updates.

    Returns void

  • Protected

    Update the batch data object.

    Returns void

  • Render with batching.

    Parameters

    • renderer: Renderer

      The renderer

    • pluginName: string

      The batch renderer

    Returns void

  • Render without batching.

    Parameters

    Returns void

  • Create a SpriteMesh from another source. You can specify texture options and a specific shader class derived from BaseSamplerShader.

    Parameters

    • source: any

      Source to create texture from.

    • Optional textureOptions: any

      See PIXI.BaseTexture's constructor for options.

    • Optional shaderClass: BaseSamplerShader

      The shader class to use. BaseSamplerShader by default.

    Returns SpriteMesh