Class Sprite

Hierarchy

  • Sprite
    • Sprite

Implements

Constructors

Properties

Accessors

Methods

Constructors

Properties

_accessibleActive?: boolean
_accessibleDiv?: AccessibleHTMLElement
_anchor: ObservablePoint
_bounds: Bounds
_boundsDirty: boolean
_filterEffect?: FilterEffect
_internalEventMode: EventMode
_localBoundsCacheData: LocalBoundsCacheData
_localBoundsCacheId: number
_maskEffect?: MaskEffect
_maskOptions?: MaskOptions
_onRender: (() => void)
_renderId?: number
_texture: Texture<TextureSource<any>>
_zIndex: number
accessible?: boolean

Flag for if the object is accessible. If true AccessibilityManager will overlay a shadow div with attributes set

false
accessibleChildren?: boolean

Setting to false will prevent any children inside this container to be accessible. Defaults to true.

true
accessibleHint?: string

Sets the aria-label attribute of the shadow div

accessiblePointerEvents?: PointerEvents

Specify the pointer-events the accessible div will use Defaults to auto.

'auto'
accessibleTitle?: string

Sets the title attribute of the shadow div If accessibleTitle AND accessibleHint has not been this will default to 'container [tabIndex]'

accessibleType?: string

Specify the type of div the accessible layer is. Screen readers treat the element differently depending on this type. Defaults to button.

'button'
boundsArea: Rectangle

An optional bounds area for this container. Setting this rectangle will stop the renderer from recursively measuring the bounds of each children and instead use this single boundArea. This is great for optimisation! If for example you have a 1000 spinning particles and you know they all sit within a specific bounds, then setting it will mean the renderer will not need to measure the 1000 children to find the bounds. Instead it will just use the bounds you set.

children: ContainerChild[]

The array of children of this container.

cullable?: boolean

Should this object be rendered if the bounds of this object are out of frame?

Culling has no effect on whether updateTransform is called.

false

scene.Container#

cullableChildren?: boolean

Determines if the children to the container can be culled Setting this to false allows PixiJS to bypass a recursive culling function Which can help to optimize very complex scenes

true

scene.Container#

cullArea?: Rectangle

If set, this shape is used for culling instead of the bounds of this object. It can improve the culling performance of objects with many children. The culling area is defined in local space.

scene.Container#

cursor?: string

The cursor preferred when the mouse pointer is hovering over.

depthOfChildModified: (() => void)
destroy$: Subject<void> = ...

When Lifecycle Object is destroyed, it emits and closes this subject. Along with destroying his children, which in turn behave the same.

destroyed: boolean

If the object has been destroyed via destroy(). If true, it should not be used.

effects?: Effect[]
eventMode?: EventMode

The mode of interaction for this object

filterArea?: Rectangle
filters: Filter | Filter[]
gameObject: LifecycleParent

Parent GameObject is assigned at creation.

groupAlpha: number
groupColor: number
groupColorAlpha: number
groupTransform: Matrix

The group transform is a transform relative to the render group it belongs too. If this container is render group then this will be an identity matrix. other wise it will be the same as the relativeGroupTransform. Use this value when actually rendering things to the screen

hitArea?: IHitArea

The hit-area specifies the area for which pointer events should be captured by this event target.

interactive?: boolean

Whether this event target should fire UI events.

interactiveChildren?: boolean

Whether this event target has any children that need UI events. This can be used optimize event propagation.

isInteractive: (() => boolean)

Returns true if the Container has interactive 'static' or 'dynamic'

label: string = 'Sprite'

Each Lifecycle Object has label for pixi debugging.

localAlpha: number
localColor: number
localTransform: Matrix

Current transform of the object based on local factors: position, scale, other stuff.

mask: Mask
name: string

since 8.0.0

Container#label

onclick?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'click' event

onglobalmousemove?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'globalmousemove' event

onglobalpointermove?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'globalpointermove' event

onglobaltouchmove?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'globaltouchmove' event

onmousedown?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'mousedown' event

onmouseenter?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'mouseenter' event

onmouseleave?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'mouseleave' event

onmousemove?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'mousemove' event

onmouseout?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'mouseout' event

onmouseover?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'mouseover' event

onmouseup?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'mouseup' event

onmouseupoutside?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'mouseupoutside' event

onpointercancel?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'pointercancel' event

onpointerdown?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'pointerdown' event

onpointerenter?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'pointerenter' event

onpointerleave?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'pointerleave' event

onpointermove?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'pointermove' event

onpointerout?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'pointerout' event

onpointerover?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'pointerover' event

onpointertap?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'pointertap' event

onpointerup?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'pointerup' event

onpointerupoutside?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'pointerupoutside' event

onRender: (() => void)
onrightclick?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'rightclick' event

onrightdown?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'rightdown' event

onrightup?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'rightup' event

onrightupoutside?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'rightupoutside' event

ontap?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'tap' event

ontouchcancel?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'touchcancel' event

ontouchend?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'touchend' event

ontouchendoutside?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'touchendoutside' event

ontouchmove?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'touchmove' event

ontouchstart?: FederatedEventHandler<FederatedPointerEvent>

Handler for 'touchstart' event

onwheel?: FederatedEventHandler<FederatedWheelEvent>

Handler for 'wheel' event

parent: Container<ContainerChild>

The display object container that contains this display object.

relativeGroupTransform: Matrix

The relative group transform is a transform relative to the render group it belongs too. It will include all parent transforms and up to the render group (think of it as kind of like a stage - but the stage can be nested). If this container is is self a render group matrix will be relative to its parent render group

setMask: ((options: Partial<MaskOptions>) => void)
sortableChildren: boolean
sortChildren: (() => void)
sortDirty: boolean
tabIndex?: number
0
uid: number

unique id for this container

update$: Subject<number> = ...

When Lifecycle Object is updated, it emits this subject. Along with updating his children, which in turn behave the same.

zIndex: number
prefixed: string | boolean

Accessors

  • get _didChangeId(): number
  • Returns number

  • get alpha(): number
  • The opacity of the object.

    Returns number

  • set alpha(value): void
  • Parameters

    • value: number

    Returns void

  • get anchor(): ObservablePoint
  • The anchor sets the origin point of the sprite. The default value is taken from the 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

    import { Sprite } from 'pixi.js';

    const sprite = new Sprite({texture: Texture.WHITE});
    sprite.anchor.set(0.5); // This will set the origin to center. (0.5) is same as (0.5, 0.5).
  • set anchor(value): void
  • Parameters

    • value: number | PointData

    Returns void

  • get angle(): number
  • The angle of the object in degrees. 'rotation' and 'angle' have the same effect on a display object; rotation is in radians, angle is in degrees.

    Returns number

  • set angle(value): void
  • Parameters

    • value: number

    Returns void

  • get blendMode(): BLEND_MODES
  • The blend mode to be applied to the sprite. Apply a value of 'normal' to reset the blend mode.

    Returns BLEND_MODES

    'normal'
    
  • set blendMode(value): void
  • Parameters

    • value: BLEND_MODES

    Returns void

  • get bounds(): Bounds
  • The local bounds of the sprite.

    Returns Bounds

  • get height(): number
  • The height of the sprite, setting this will actually modify the scale to achieve the value set.

    Returns number

  • set height(value): void
  • The height of the Container, setting this will actually modify the scale to achieve the value set.

    Parameters

    • value: number

    Returns void

    scene.Container#

  • get isRenderable(): boolean
  • Whether or not the object should be rendered.

    Returns boolean

  • get isRenderGroup(): boolean
  • Returns true if this container is a render group. This means that it will be rendered as a separate pass, with its own set of instructions

    Returns boolean

  • set isRenderGroup(value): void
  • Parameters

    • value: boolean

    Returns void

  • get pivot(): ObservablePoint
  • The center of rotation, scaling, and skewing for this display object in its local space. The position is the projection of pivot in the parent's local space.

    By default, the pivot is the origin (0, 0).

    Returns ObservablePoint

    4.0.0

  • set pivot(value): void
  • Parameters

    • value: number | PointData

    Returns void

  • get position(): ObservablePoint
  • The coordinate of the object relative to the local coordinates of the parent.

    Returns ObservablePoint

    4.0.0

  • set position(value): void
  • Parameters

    • value: PointData

    Returns void

  • get renderable(): boolean
  • Can this object be rendered, if false the object will not be drawn but the transform will still be updated.

    Returns boolean

  • set renderable(value): void
  • Parameters

    • value: boolean

    Returns void

  • get rotation(): number
  • The rotation of the object in radians. 'rotation' and 'angle' have the same effect on a display object; rotation is in radians, angle is in degrees.

    Returns number

  • set rotation(value): void
  • Parameters

    • value: number

    Returns void

  • get roundPixels(): boolean
  • Whether or not to round the x/y position of the sprite.

    Returns boolean

  • set roundPixels(value): void
  • Whether or not to round the x/y position of the object.

    Parameters

    • value: boolean

    Returns void

  • get scale(): ObservablePoint
  • The scale factors of this object along the local coordinate axes.

    The default scale is (1, 1).

    Returns ObservablePoint

    4.0.0

  • set scale(value): void
  • Parameters

    • value: number | PointData

    Returns void

  • get skew(): ObservablePoint
  • The skew factor for the object in radians.

    Returns ObservablePoint

    4.0.0

  • set skew(value): void
  • Parameters

    • value: PointData

    Returns void

  • get sourceBounds(): BoundsData
  • The bounds of the sprite, taking the texture's trim into account.

    Returns BoundsData

  • get texture(): Texture<TextureSource<any>>
  • The texture that the sprite is using.

    Returns Texture<TextureSource<any>>

  • set texture(value): void
  • Parameters

    • value: Texture<TextureSource<any>>

    Returns void

  • 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

    0xFFFFFF
    
  • set tint(value): void
  • Parameters

    • value: ColorSource

    Returns void

  • get visible(): boolean
  • The visibility of the object. If false the object will not be drawn, and the transform will not be updated.

    Returns boolean

  • set visible(value): void
  • Parameters

    • value: boolean

    Returns void

  • get width(): number
  • The width of the sprite, setting this will actually modify the scale to achieve the value set.

    Returns number

  • set width(value): void
  • The width of the Container, setting this will actually modify the scale to achieve the value set.

    Parameters

    • value: number

    Returns void

    scene.Container#

  • get worldTransform(): Matrix
  • Current transform of the object based on world (parent) factors.

    Returns Matrix

  • get x(): number
  • The position of the container on the x axis relative to the local coordinates of the parent. An alias to position.x

    Returns number

  • set x(value): void
  • Parameters

    • value: number

    Returns void

  • get y(): number
  • The position of the container on the y axis relative to the local coordinates of the parent. An alias to position.y

    Returns number

  • set y(value): void
  • Parameters

    • value: number

    Returns void

Methods

  • Parameters

    • height: number
    • localHeight: number

    Returns void

  • Parameters

    • width: number
    • localWidth: number

    Returns void

  • Adds the bounds of this object to the bounds object.

    Parameters

    • bounds: Bounds

      The output bounds object.

    Returns void

  • Adds one or more children to the container.

    Multiple items can be added like so: myContainer.addChild(thingOne, thingTwo, thingThree)

    Type Parameters

    • U extends ContainerChild[]

    Parameters

    • Rest...children: U

      The Container(s) to add to the container

    Returns U[0]

    • The first child that was added.
  • Type Parameters

    • U extends ContainerChild

    Parameters

    • child: U
    • index: number

    Returns U

  • Parameters

    • effect: Effect

    Returns void

  • Type Parameters

    • K extends (keyof FederatedEventMap) | (keyof GlobalFederatedEventMap)

    Parameters

    • type: K
    • listener: ((e: AllFederatedEventMap[K]) => any)
        • (e): any
        • Parameters

          • e: AllFederatedEventMap[K]

          Returns any

    • Optionaloptions: AddListenerOptions

    Returns void

  • Parameters

    • type: string
    • listener: EventListenerOrEventListenerObject
    • Optionaloptions: AddListenerOptions

    Returns void

  • Type Parameters

    • T extends (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)

    Parameters

    • event: T
    • fn: ((...args: ArgumentMap<ContainerEvents<ContainerChild> & AnyEvent>[Extract<T, (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)>]) => void)
        • (...args): void
        • Parameters

          • Rest...args: ArgumentMap<ContainerEvents<ContainerChild> & AnyEvent>[Extract<T, (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)>]

          Returns void

    • Optionalcontext: any

    Returns this

  • Checks if the object contains the given point.

    Parameters

    • point: PointData

      The point to check

    Returns boolean

  • This will disable the render group for this container.

    Returns void

  • Parameters

    • e: FederatedEvent<UIEvent | PixiTouch>

    Returns boolean

  • Calls each of the listeners registered for a given event.

    Type Parameters

    • T extends (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)

    Parameters

    • event: T
    • Rest...args: ArgumentMap<ContainerEvents<ContainerChild> & AnyEvent>[Extract<T, (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)>]

    Returns boolean

  • Calling this enables a render group for this container. This means it will be rendered as a separate set of instructions. The transform of the container will also be handled on the GPU rather than the CPU.

    Returns void

  • Return an array listing the events for which the emitter has registered listeners.

    Returns ((keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent))[]

  • Parameters

    • OptionalskipUpdate: boolean
    • Optionalbounds: Bounds

    Returns Bounds

  • Type Parameters

    • U extends ContainerChild

    Parameters

    • index: number

    Returns U

  • Parameters

    • label: string | RegExp
    • Optionaldeep: boolean

    Returns Container<ContainerChild>

  • Parameters

    • label: string | RegExp
    • Optionaldeep: boolean

    Returns Container<ContainerChild>

  • Parameters

    • child: ContainerChild

    Returns number

  • Parameters

    • label: string | RegExp
    • Optionaldeep: boolean
    • Optionalout: Container<ContainerChild>[]

    Returns Container<ContainerChild>[]

  • Parameters

    • Optionalpoint: Point
    • OptionalskipUpdate: boolean

    Returns Point

  • Parameters

    • Optionalbounds: Bounds

    Returns Bounds

  • Retrieves the size of the Sprite as a [Size]Size object. This is faster than get the width and height separately.

    Parameters

    • Optionalout: Size

      Optional object to store the size in.

    Returns Size

    • The size of the Sprite.
  • Return the number of listeners listening to a given event.

    Parameters

    • event: (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)

    Returns number

  • Return the listeners registered for a given event.

    Type Parameters

    • T extends (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)

    Parameters

    • event: T

    Returns ((...args: ArgumentMap<ContainerEvents<ContainerChild> & AnyEvent>[Extract<T, (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)>]) => void)[]

  • Type Parameters

    • T extends (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)

    Parameters

    • event: T
    • Optionalfn: ((...args: ArgumentMap<ContainerEvents<ContainerChild> & AnyEvent>[Extract<T, (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)>]) => void)
        • (...args): void
        • Parameters

          • Rest...args: ArgumentMap<ContainerEvents<ContainerChild> & AnyEvent>[Extract<T, (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)>]

          Returns void

    • Optionalcontext: any
    • Optionalonce: boolean

    Returns this

  • Add a listener for a given event.

    Type Parameters

    • T extends (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)

    Parameters

    • event: T
    • fn: ((...args: ArgumentMap<ContainerEvents<ContainerChild> & AnyEvent>[Extract<T, (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)>]) => void)
        • (...args): void
        • Parameters

          • Rest...args: ArgumentMap<ContainerEvents<ContainerChild> & AnyEvent>[Extract<T, (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)>]

          Returns void

    • Optionalcontext: any

    Returns this

  • Add a one-time listener for a given event.

    Type Parameters

    • T extends (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)

    Parameters

    • event: T
    • fn: ((...args: ArgumentMap<ContainerEvents<ContainerChild> & AnyEvent>[Extract<T, (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)>]) => void)
        • (...args): void
        • Parameters

          • Rest...args: ArgumentMap<ContainerEvents<ContainerChild> & AnyEvent>[Extract<T, (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)>]

          Returns void

    • Optionalcontext: any

    Returns this

  • Remove all listeners, or those of the specified event.

    Parameters

    • Optionalevent: (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)

    Returns this

  • Removes one or more children from the container.

    Type Parameters

    • U extends ContainerChild[]

    Parameters

    • Rest...children: U

      The Container(s) to remove

    Returns U[0]

    The first child that was removed.

  • Type Parameters

    • U extends ContainerChild

    Parameters

    • index: number

    Returns U

  • Parameters

    • OptionalbeginIndex: number
    • OptionalendIndex: number

    Returns ContainerChild[]

  • Parameters

    • effect: Effect

    Returns void

  • Type Parameters

    • K extends (keyof FederatedEventMap) | (keyof GlobalFederatedEventMap)

    Parameters

    • type: K
    • listener: ((e: AllFederatedEventMap[K]) => any)
        • (e): any
        • Parameters

          • e: AllFederatedEventMap[K]

          Returns any

    • Optionaloptions: RemoveListenerOptions

    Returns void

  • Parameters

    • type: string
    • listener: EventListenerOrEventListenerObject
    • Optionaloptions: RemoveListenerOptions

    Returns void

  • Returns void

  • Remove the listeners of a given event.

    Type Parameters

    • T extends (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)

    Parameters

    • event: T
    • Optionalfn: ((...args: ArgumentMap<ContainerEvents<ContainerChild> & AnyEvent>[Extract<T, (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)>]) => void)
        • (...args): void
        • Parameters

          • Rest...args: ArgumentMap<ContainerEvents<ContainerChild> & AnyEvent>[Extract<T, (keyof ContainerEvents<ContainerChild>) | (keyof AnyEvent)>]

          Returns void

    • Optionalcontext: any
    • Optionalonce: boolean

    Returns this

  • Type Parameters

    • U extends ContainerChild[]

    Parameters

    • Rest...child: U

    Returns U[0]

  • Type Parameters

    • U extends ContainerChild

    Parameters

    • child: U
    • index: number

    Returns U

  • Parameters

    • child: ContainerChild
    • index: number

    Returns void

  • Updates the local transform using the given matrix.

    Parameters

    • matrix: Matrix

      The matrix to use for updating the transform.

    Returns void

  • Sets the size of the Sprite to the specified width and height. This is faster than setting the width and height separately.

    Parameters

    • value: number | Optional<Size, "height">

      This can be either a number or a [Size]Size object.

    • Optionalheight: number

      The height to set. Defaults to the value of width if not provided.

    Returns void

  • Type Parameters

    • U extends ContainerChild

    Parameters

    • child: U
    • child2: U

    Returns void

  • Type Parameters

    • P extends PointData = Point

    Parameters

    • position: PointData
    • Optionalpoint: P
    • OptionalskipUpdate: boolean

    Returns P

  • Type Parameters

    • P extends PointData = Point

    Parameters

    • position: PointData
    • Optionalfrom: Container<ContainerChild>
    • Optionalpoint: P
    • OptionalskipUpdate: boolean

    Returns P

  • Updates the local transform.

    Returns void

  • Updates the transform properties of the container (accepts partial values).

    Parameters

    • opts: Partial<UpdateTransformOptions>

      The options for updating the transform.

    Returns this

  • Helper function that creates a new sprite based on the source you provide. The source can be - frame id, image, video, canvas element, video element, texture

    Parameters

    • source: Texture<TextureSource<any>> | TextureSourceLike

      Source to create texture from

    • OptionalskipCache: boolean

      Whether to skip the cache or not

    Returns Sprite

    The newly created sprite

  • Mixes all enumerable properties and methods from a source object to Container.

    Parameters

    • source: Dict<any>

      The source of properties and methods to mix in.

    Returns void