easy-scratch/doc/scratch-vm/Sprite.html

1279 lines
80 KiB
HTML
Raw Normal View History

2025-02-12 12:27:32 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Sprite - Documentation</title>
<script src="scripts/prettify/prettify.js"></script>
<script src="scripts/prettify/lang-css.js"></script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
<script src="scripts/nav.js" defer></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<input type="checkbox" id="nav-trigger" class="nav-trigger" />
<label for="nav-trigger" class="navicon-button x">
<div class="navicon"></div>
</label>
<label for="nav-trigger" class="overlay"></label>
<nav >
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="-_StackFrame.html">_StackFrame</a><ul class='methods'><li data-type='method'><a href="-_StackFrame.html#.create">create</a></li><li data-type='method'><a href="-_StackFrame.html#.release">release</a></li><li data-type='method'><a href="-_StackFrame.html#reset">reset</a></li><li data-type='method'><a href="-_StackFrame.html#reuse">reuse</a></li></ul></li><li><a href="BLE.html">BLE</a><ul class='methods'><li data-type='method'><a href="BLE.html#connectPeripheral">connectPeripheral</a></li><li data-type='method'><a href="BLE.html#didReceiveCall">didReceiveCall</a></li><li data-type='method'><a href="BLE.html#disconnect">disconnect</a></li><li data-type='method'><a href="BLE.html#handleDisconnectError">handleDisconnectError</a></li><li data-type='method'><a href="BLE.html#isConnected">isConnected</a></li><li data-type='method'><a href="BLE.html#read">read</a></li><li data-type='method'><a href="BLE.html#requestPeripheral">requestPeripheral</a></li><li data-type='method'><a href="BLE.html#startNotifications">startNotifications</a></li><li data-type='method'><a href="BLE.html#write">write</a></li></ul></li><li><a href="BlockCached.html">BlockCached</a></li><li><a href="Blocks.html">Blocks</a><ul class='methods'><li data-type='method'><a href="Blocks.html#_addScript">_addScript</a></li><li data-type='method'><a href="Blocks.html#_deleteScript">_deleteScript</a></li><li data-type='method'><a href="Blocks.html#_getBackdropField">_getBackdropField</a></li><li data-type='method'><a href="Blocks.html#_getBlockParams">_getBlockParams</a></li><li data-type='method'><a href="Blocks.html#_getCostumeField">_getCostumeField</a></li><li data-type='method'><a href="Blocks.html#_getCustomBlockInternal">_getCustomBlockInternal</a></li><li data-type='method'><a href="Blocks.html#_getSoundField">_getSoundField</a></li><li data-type='method'><a href="Blocks.html#_getSpriteField">_getSpriteField</a></li><li data-type='method'><a href="Blocks.html#blocklyListen">blocklyListen</a></li><li data-type='method'><a href="Blocks.html#blockToXML">blockToXML</a></li><li data-type='method'><a href="Blocks.html#changeBlock">changeBlock</a></li><li data-type='method'><a href="Blocks.html#createBlock">createBlock</a></li><li data-type='method'><a href="Blocks.html#deleteBlock">deleteBlock</a></li><li data-type='method'><a href="Blocks.html#emitProjectChanged">emitProjectChanged</a></li><li data-type='method'><a href="Blocks.html#getAllVariableAndListReferences">getAllVariableAndListReferences</a></li><li data-type='method'><a href="Blocks.html#getBlock">getBlock</a></li><li data-type='method'><a href="Blocks.html#getBranch">getBranch</a></li><li data-type='method'><a href="Blocks.html#getFields">getFields</a></li><li data-type='method'><a href="Blocks.html#getInputs">getInputs</a></li><li data-type='method'><a href="Blocks.html#getMutation">getMutation</a></li><li data-type='method'><a href="Blocks.html#getNextBlock">getNextBlock</a></li><li data-type='method'><a href="Blocks.html#getOpcode">getOpcode</a></li><li data-type='method'><a href="Blocks.html#getProcedureDefinition">getProcedureDefinition</a></li><li data-type='method'><a href="Blocks.html#getProcedureParamNamesAndIds">getProcedureParamNamesAndIds</a></li><li data-type='method'><a href="Blocks.html#getProcedureParamNamesIdsAndDefaults">getProcedureParamNamesIdsAndDefaults</a></li><li data-type='method'><a href="Blocks.html#getScripts">getScripts</a></li><li data-type='method'><a href="Blocks.html#getTopLevelScript">getTopLevelScript</a></li><li data-type='method'><a href="Blocks.html#moveBlock">moveBlock</a></li><li data-type='method'><a href="Blocks.html#mutationToXML">mutationToXML</a></li><li data-type='method'><a href="Blocks.html#resetCache">resetCache</a></li><li data-type='method'><a href="Blocks.html#runAllMonitored">runAllMonitored</a></li><li data-type='method'><a href="Blocks.html#toXML">toXML</a></li><li data-type='method'><a href="Blocks.html#updateAssetName">updateAssetName</a></li><li data-type='method'><a href
</nav>
<div id="main">
<h1 class="page-title">Sprite</h1>
<section>
<header>
<h2>
Sprite
</h2>
</header>
<article>
<div class="container-overview">
<h4 class="name" id="Sprite"><span class="type-signature"></span>new Sprite<span class="signature">(blocks<span class="signature-attributes">nullable</span>, runtime)</span><span class="type-signature"></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Sprite to be used on the Scratch stage.
All clones of a sprite have shared blocks, shared costumes, shared variables,
shared sounds, etc.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>blocks</code></td>
<td class="type">
<span class="param-type"><a href="Blocks.html">Blocks</a></span>
</td>
<td class="attributes">
&lt;nullable><br>
</td>
<td class="description last"><p>Shared blocks object for all clones of sprite.</p></td>
</tr>
<tr>
<td class="name"><code>runtime</code></td>
<td class="type">
<span class="param-type"><a href="Runtime.html">Runtime</a></span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>Reference to the runtime.</p></td>
</tr>
</tbody>
</table>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="clones"><span class="type-signature"></span>clones<span class="type-signature"> :Array.&lt;!<a href="RenderedTarget.html">RenderedTarget</a>></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>List of clones for this sprite, including the original.</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Array.&lt;!<a href="RenderedTarget.html">RenderedTarget</a>></span>
</li>
</ul>
<h4 class="name" id="costumes"><span class="type-signature"></span>costumes<span class="type-signature"></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Add an array of costumes, taking care to avoid duplicate names.</p>
</div>
<h4 class="name" id="costumes"><span class="type-signature"></span>costumes<span class="type-signature"></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Get full costume list</p>
</div>
<h4 class="name" id="costumes_"><span class="type-signature"></span>costumes_<span class="type-signature"> :Array.&lt;!Object></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>List of costumes for this sprite.
Each entry is an object, e.g.,
{
skinId: 1,
name: &quot;Costume Name&quot;,
bitmapResolution: 2,
rotationCenterX: 0,
rotationCenterY: 0
}</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">Array.&lt;!Object></span>
</li>
</ul>
<h4 class="name" id="name"><span class="type-signature"></span>name<span class="type-signature"> :string</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Human-readable name for this sprite (and all clones).</p>
</div>
<h5>Type:</h5>
<ul>
<li>
<span class="param-type">string</span>
</li>
</ul>
<h4 class="name" id="sounds"><span class="type-signature"></span>sounds<span class="type-signature"></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>List of sounds for this sprite.</p>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="addCostumeAt"><span class="type-signature"></span>addCostumeAt<span class="signature">(costumeObject<span class="signature-attributes">non-null</span>, index<span class="signature-attributes">non-null</span>)</span><span class="type-signature"></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Add a costume at the given index, taking care to avoid duplicate names.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>costumeObject</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><p>Object representing the costume.</p></td>
</tr>
<tr>
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">int</span>
</td>
<td class="description last"><p>Index at which to add costume</p></td>
</tr>
</tbody>
</table>
<h4 class="name" id="createClone"><span class="type-signature"></span>createClone<span class="signature">(optLayerGroup<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; (non-null) {<a href="RenderedTarget.html">RenderedTarget</a>}</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Create a clone of this sprite.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>optLayerGroup</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
&lt;optional><br>
</td>
<td class="description last"><p>Optional layer group the clone's drawable should be added to
Defaults to the sprite layer group</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>Newly created clone.</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type"><a href="RenderedTarget.html">RenderedTarget</a></span>
</dd>
</dl>
<h4 class="name" id="deleteCostumeAt"><span class="type-signature"></span>deleteCostumeAt<span class="signature">(index)</span><span class="type-signature"> &rarr; (nullable) {object}</span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Delete a costume by index.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>index</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="description last"><p>Costume index to be deleted</p></td>
</tr>
</tbody>
</table>
<h5>Returns:</h5>
<div class="param-desc">
<p>The deleted costume</p>
</div>
<dl class="param-type">
<dt>
Type
</dt>
<dd>
<span class="param-type">object</span>
</dd>
</dl>
<h4 class="name" id="removeClone"><span class="type-signature"></span>removeClone<span class="signature">(clone<span class="signature-attributes">non-null</span>)</span><span class="type-signature"></span></h4>
<dl class="details">
</dl>
<div class="description">
<p>Disconnect a clone from this sprite. The clone is unmodified.
In particular, the clone's dispose() method is not called.</p>
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>clone</code></td>
<td class="type">
<span class="param-type"><a href="RenderedTarget.html">RenderedTarget</a></span>
</td>
<td class="description last"><p>the clone to be removed.</p></td>
</tr>
</tbody>
</table>
</article>
</section>
</div>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.6.3</a> using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
</footer>
<script>prettyPrint();</script>
<script src="scripts/polyfill.js"></script>
<script src="scripts/linenumber.js"></script>
</body>
</html>