Class Sprite
Hierarchy
- ThinSprite
- Sprite
Implements
Constructors
constructor
-
Creates a new Sprite
Parameters
- name: string
defines the name
- manager: ISpriteManager
defines the manager
Returns Sprite
- name: string
Properties
action Manager
Gets or sets the associated action manager
angle
Gets or sets rotation angle
animations
Gets the list of attached animations
cell Index
Gets or sets the cell index in the sprite sheet
cell Ref
Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet
color
Gets or sets the main color
dispose When Finished Animating
Gets or sets a boolean indicating that this sprite should be disposed after animation ends
height
Gets or sets the height
invert U
Gets or sets a boolean indicating if UV coordinates should be inverted in U axis
invert V
Gets or sets a boolean indicating if UV coordinates should be inverted in B axis
is Pickable
Gets or sets a boolean indicating if the sprite can be picked
is Visible
Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
name
defines the name
on Dispose Observable
An event triggered when the control has been disposed
position
Gets or sets the current world position
unique Id
Gets or sets the unique id of the sprite
use Alpha For Picking
Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default)
width
Gets or sets the width
Accessors
animation Started
-
get animationStarted(): boolean
Returns a boolean indicating if the animation is started
Returns boolean
delay
-
get delay(): number
Gets or sets the delay between cell changes (setting it will restart the animation)
Returns number
-
set delay(value: number): void
Gets or sets the delay between cell changes (setting it will restart the animation)
Parameters
- value: number
Returns void
from Index
-
get fromIndex(): number
Gets or sets the initial key for the animation (setting it will restart the animation)
Returns number
-
set fromIndex(value: number): void
Gets the initial key for the animation (setting it will restart the animation)
Parameters
- value: number
Returns void
loop Animation
-
get loopAnimation(): boolean
Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation)
Returns boolean
-
set loopAnimation(value: boolean): void
Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation)
Parameters
- value: boolean
Returns void
manager
-
Gets the manager of this sprite
Returns ISpriteManager
size
-
get size(): number
Gets or sets the sprite size
Returns number
-
set size(value: number): void
Parameters
- value: number
Returns void
to Index
-
get toIndex(): number
Gets or sets the end key for the animation (setting it will restart the animation)
Returns number
-
set toIndex(value: number): void
Gets or sets the end key for the animation (setting it will restart the animation)
Parameters
- value: number
Returns void
Methods
dispose
-
Release associated resources
Returns void
get Class Name
-
Returns the string "Sprite"
Returns string
"Sprite"
play Animation
-
playAnimation(
from: number,
to: number,
loop: boolean,
delay: number,
onAnimationEnd?: Nullable<() => void>,
): voidStarts an animation
Parameters
- from: number
defines the initial key
- to: number
defines the end key
- loop: boolean
defines if the animation must loop
- delay: number
defines the start delay (in ms)
- onAnimationEnd: Nullable<() => void> = null
defines a callback to call when animation ends
Returns void
- from: number
serialize
-
Serializes the sprite to a JSON object
Returns any
the JSON object
stop Animation
-
Stops current animation (if any)
Returns void
StaticParse
-
Parses a JSON object to create a new sprite
Parameters
- parsedSprite: any
The JSON object to parse
- manager: SpriteManager
defines the hosting manager
Returns Sprite
the new sprite
- parsedSprite: any
Class used to represent a sprite
See
https://doc.babylonjs.com/features/featuresDeepDive/sprites