new Sprite(blocksnullable, runtime)
Sprite to be used on the Scratch stage. All clones of a sprite have shared blocks, shared costumes, shared variables, shared sounds, etc.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
blocks |
Blocks |
<nullable> |
Shared blocks object for all clones of sprite. |
runtime |
Runtime | Reference to the runtime. |
Members
clones :Array.<!RenderedTarget>
List of clones for this sprite, including the original.
Type:
- Array.<!RenderedTarget>
costumes
Add an array of costumes, taking care to avoid duplicate names.
costumes
Get full costume list
costumes_ :Array.<!Object>
List of costumes for this sprite. Each entry is an object, e.g., { skinId: 1, name: "Costume Name", bitmapResolution: 2, rotationCenterX: 0, rotationCenterY: 0 }
Type:
- Array.<!Object>
name :string
Human-readable name for this sprite (and all clones).
Type:
- string
sounds
List of sounds for this sprite.
Methods
addCostumeAt(costumeObjectnon-null, indexnon-null)
Add a costume at the given index, taking care to avoid duplicate names.
Parameters:
Name | Type | Description |
---|---|---|
costumeObject |
object | Object representing the costume. |
index |
int | Index at which to add costume |
createClone(optLayerGroupopt) → (non-null) {RenderedTarget}
Create a clone of this sprite.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
optLayerGroup |
string |
<optional> |
Optional layer group the clone's drawable should be added to Defaults to the sprite layer group |
Returns:
Newly created clone.
- Type
- RenderedTarget
deleteCostumeAt(index) → (nullable) {object}
Delete a costume by index.
Parameters:
Name | Type | Description |
---|---|---|
index |
number | Costume index to be deleted |
Returns:
The deleted costume
- Type
- object
removeClone(clonenon-null)
Disconnect a clone from this sprite. The clone is unmodified. In particular, the clone's dispose() method is not called.
Parameters:
Name | Type | Description |
---|---|---|
clone |
RenderedTarget | the clone to be removed. |