FlxSprite
Renderer-neutral Flixel sprite state with adapter-owned Pixi views.
export declare class FlxSprite extends FlxObjectConstructors
constructor(x?: number, y?: number, simpleGraphic?: FlxGraphic | Texture | null)Constructs a new instance of the FlxSprite class
| Parameter | Type | Description |
|---|---|---|
x | number | - |
y | number | - |
simpleGraphic | FlxGraphic | Texture | null | - |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
alpha | - | number | - |
animation | readonly | FlxAnimationController | - |
animationFrame | readonly | number | - |
animationName | readonly | string | null | - |
animationPaused | readonly | boolean | - |
antialiasing | - | boolean | - |
blend | - | BLEND_MODES | null | - |
color | - | number | - |
dirty | - | boolean | - |
facing | - | number | - |
filterArea | - | Readonly<RectangleLike> | null | Optional local render rectangle that skips automatic filter bounds measurement. |
filters | - | readonly FlxFilter[] | Immutable renderer-neutral effects applied in declaration order. |
finished | - | boolean | - |
frame | - | number | - |
frameCollection | readonly | FlxFramesCollection | null | - |
frameHeight | - | number | - |
frames | - | number | - |
frameWidth | - | number | - |
offset | - | FlxPoint | - |
origin | - | FlxPoint | - |
renderHandleCount | readonly | number | Number of live adapter handles owned by this gameplay object. |
scale | - | FlxPoint | - |
Methods
addAnimation()
addAnimation(name: string, frames: readonly number[] | FlxAtlasFrameList, frameRateOrOptions?: number | FlxAtlasAnimationOptions, looped?: boolean): voidRegister a named animation.
Strip form (legacy-compatible):
sprite.addAnimation('walk', [0, 1, 2], 12, true);Atlas frame form:
sprite.addAnimation('walk', atlas.framesByPrefix('walk_', 1, 2), {
frameWidth: 64,
frameHeight: 128,
});Atlas frames are baked into a shared strip internally (append-only).
Replaces any existing animation with the same name.
Parameters:
| Parameter | Type | Description |
|---|---|---|
name | string | - |
frames | readonly number[] | FlxAtlasFrameList | - |
frameRateOrOptions | number | FlxAtlasAnimationOptions | - |
looped | boolean | - |
Returns: void
addAnimationCallback()
addAnimationCallback(callback: FlxAnimationCallback | null): voidParameters:
| Parameter | Type | Description |
|---|---|---|
callback | FlxAnimationCallback | null | - |
Returns: void
centerOffsets()
centerOffsets(adjustPosition?: boolean): voidParameters:
| Parameter | Type | Description |
|---|---|---|
adjustPosition | boolean | - |
Returns: void
clearFilterArea()
clearFilterArea(): thisRestore automatic filter bounds measurement.
Returns: this
createRenderHandle()
createRenderHandle(): FlxRenderHandleReturns: FlxRenderHandle
destroy()
destroy(): voidReturns: void
draw()
draw(): voidReturns: void
drawFrame()
drawFrame(force?: boolean): voidParameters:
| Parameter | Type | Description |
|---|---|---|
force | boolean | - |
Returns: void
loadFrames()
loadFrames(collection: FlxFramesCollection, reverse?: boolean): thisLoads named texture views without baking them into a new strip.
Parameters:
| Parameter | Type | Description |
|---|---|---|
collection | FlxFramesCollection | - |
reverse | boolean | - |
Returns: this
loadGraphic()
loadGraphic(source: FlxGraphic | Texture, animated?: boolean, reverse?: boolean, width?: number, height?: number, unique?: boolean): thisParameters:
| Parameter | Type | Description |
|---|---|---|
source | FlxGraphic | Texture | - |
animated | boolean | - |
reverse | boolean | - |
width | number | - |
height | number | - |
unique | boolean | - |
Returns: this
loadPixelBuffer()
protected loadPixelBuffer(buffer: PixelBuffer, key?: string): thisInstalls a generated CPU pixel buffer as this sprite's owned texture.
Parameters:
| Parameter | Type | Description |
|---|---|---|
buffer | PixelBuffer | - |
key | string | - |
Returns: this
makeGraphic()
makeGraphic(width: number, height: number, color?: number, unique?: boolean, key?: string | null): thisParameters:
| Parameter | Type | Description |
|---|---|---|
width | number | - |
height | number | - |
color | number | - |
unique | boolean | - |
key | string | null | - |
Returns: this
onScreen()
onScreen(camera?: FlxCameraLike): booleanParameters:
| Parameter | Type | Description |
|---|---|---|
camera | FlxCameraLike | - |
Returns: boolean
pauseAnimation()
pauseAnimation(): voidReturns: void
play()
play(name: string, forceOrOptions?: boolean | FlxAnimationPlayOptions): voidPlay a named animation.
Legacy form: play(name) or play(name, force: boolean) — uses the looped / frameRate values stored when addAnimation was called.
Options form: play(name, { loop, speed, force }) - loop defaults to false - speed defaults to 1 (one anim frame per game update) - force defaults to false
Parameters:
| Parameter | Type | Description |
|---|---|---|
name | string | - |
forceOrOptions | boolean | FlxAnimationPlayOptions | - |
Returns: void
postUpdate()
postUpdate(): voidReturns: void
randomFrame()
randomFrame(): voidReturns: void
restartAnimation()
restartAnimation(): voidReturns: void
resumeAnimation()
resumeAnimation(): voidReturns: void
setFilterArea()
setFilterArea(x: number, y: number, width: number, height: number): thisDefine a local render rectangle for filter bounds optimization.
Parameters:
| Parameter | Type | Description |
|---|---|---|
x | number | - |
y | number | - |
width | number | - |
height | number | - |
Returns: this
setOriginToCorner()
setOriginToCorner(): voidReturns: void
syncRenderHandles()
syncRenderHandles(): voidReturns: void
trackRenderHandle()
protected trackRenderHandle<T extends FlxRenderHandle>(create: (onDestroy: () => void) => T): TParameters:
| Parameter | Type | Description |
|---|---|---|
create | (onDestroy: () => void) => T | - |
Returns: T
updateAnimation()
protected updateAnimation(): voidReturns: void