new Sprite()
Members
-
lastClickTime :number
-
The last time this Sprite was clicked, or 0 if never clicked, in millis since epoch.
Type:
- number
Methods
-
_getCurrentCostumeObject() → {PodJS.ScratchPod.Costume}
-
Return the currently active costume object for this Sprite
This method is intended for internal use and may change in the future.
Returns:
- Type
- PodJS.ScratchPod.Costume
-
createListVariable(name)
-
Create a new list variable with the given name.
Parameters:
Name Type Description namestring the name of the list variable -
createVariable(name)
-
Create a new variable with the given name.
Parameters:
Name Type Description namestring the name of the variable -
getDirection()
-
Returns the current direction of the sprite, in degrees normalized to 0 (inclusive) to 360 (exclusive).
-
getListVariable(name)
-
Get the given list variable.
Parameters:
Name Type Description namestring the name of the list variable Returns:
The list variable. -
getVariable(name)
-
Get the value of the given variable.
Parameters:
Name Type Description namestring the name of the variable Returns:
The value of the variable. -
getVariableNames() → {string[]}
-
Returns the names of all the variables for this sprite.
Returns:
The names of all the variables- Type
- string[]
-
go_xy(x, y)
-
Sets the sprite's X and Y position to the specified amounts.
Parameters:
Name Type Description xnumber The x position, in pixels. ynumber The y position, in pixels. -
hasListVariable(name) → {boolean}
-
Returns true if the list variable exists for this sprite, or false if not.
Parameters:
Name Type Description namestring the name of the list variable Returns:
true if the list variable exists or false if not.- Type
- boolean
-
hasVariable(name) → {boolean}
-
Returns true if the variable exists for this sprite, or false if not.
Parameters:
Name Type Description namestring the name of the variable Returns:
true if the variable exists or false if not.- Type
- boolean
-
hide()
-
Shortcut for setShown(false)
-
isShown() → {boolean}
-
Returns whether this sprite is being shown or not.
Returns:
true if this is to be shown or false if not.- Type
- boolean
-
loadCostume(name, src, scale)
-
Load and register a new costume for this sprite.
Parameters:
Name Type Description namestring the name of the costume srcstring the href of where to find the image of the costume. scalenumber (optional) - if specified, scale the image up or down by this amount, defaults to 1.0. -
loadSound(name, src)
-
Load and register an audio file for this sprite.
Parameters:
Name Type Description namestring the name of the audio srcstring the href of where to find the audio file. -
moveSteps(steps)
-
Move this sprite the given number of steps.
Parameters:
Name Type Description stepsnumber The number of steps to move the Sprite, in the forward direction. -
playSound(name)
-
Stop playing any sounds and play a new sound.
Parameters:
Name Type Description namestring the id of the sound to play -
setCostume(name)
-
Change costume for this Sprite
Parameters:
Name Type Description namestring the name of the costume to change into, matching the name provided to loadCostume. -
setDirection(degrees)
-
Point this sprite in the direction given
Parameters:
Name Type Description degreesnumber The number of steps to move the Sprite, in the x direction. -
setShown(show)
-
Changes whether this sprite is being shown or not.
Parameters:
Name Type Description showboolean true if this is to be shown or false if not. -
setVariable(name, value)
-
Set the value of the given variable to the given value.
Parameters:
Name Type Description namestring the name of the variable valuenumber | string the value to set the variable to -
show()
-
Shortcut for setShown(true)
-
showListVariable(name, shown, x, y, width, height)
-
Sets whether this list variable is shown on the stage, and the location at which it is shown.
Parameters:
Name Type Description namestring the name of the list variable shownboolean true if the list variable is to be shown, or false if not. Optional, defaults to true. xnumber x position of the list variable on the stage (optional, defaults to 0) ynumber y position of the list variable on the stage (optional, defaults to 0) widthnumber width Width of the box to show (optional, defaults to enough width to show small ints) heightnumber height of the box to show (optional, defaults to 8 rows worth of pixels) -
showVariable(name, shown, x, y)
-
Sets whether this variable is shown on the stage, and the location at which it is shown.
Parameters:
Name Type Description namestring the name of the variable shownboolean true if the variable is to be shown, or false if not. Optional, defaults to true. xnumber x position of the variable on the stage (optional, defaults to 0) ynumber y position of the variable on the stage (optional, defaults to 0) -
stopAllSounds()
-
Stop playing any sounds for this sprite.
-
tick()
-
Gets called periodically by the environment when the next action is to take place.
-
translate(x, y)
-
Move this sprite the given number of steps in the X and Y directions.
Parameters:
Name Type Description xnumber The number of steps to move the Sprite, in the x direction. ynumber The number of steps to move the Sprite, in the y direction.