Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins #58

Merged
merged 11 commits into from Feb 23, 2019
2 changes: 1 addition & 1 deletion dist/core.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/gameLoop.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/plugin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/pointer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion dist/sprite.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions docs/api/gameLoop.html
Expand Up @@ -69,6 +69,12 @@ <h1>Kontra&#8203;.gameLoop(&#8203;properties)</h1>
<h2 id="toc"><a href="#toc" class="section-link">Table of Contents<span aria-hidden="true">#</span></a></h2>

<ul aria-labeledby="toc">
<li>
<ul>
<li><a href="#lifecycle">Lifecycle Events</a></li></li>
</ul>
</li>

<li>
<h3 id="properties">Properties</h3>
<ul aria-labeledby="properties">
Expand All @@ -92,6 +98,20 @@ <h3 id="methods">Methods</h3>



<section>
<h2 id="lifecycle"><a href="#lifecycle" class="section-link">Lifecycle Events<span aria-hidden="true">#</span></a></h2>

<p>Every frame it will emit a <code>tick</code> event.</p>

<pre><code class="language-javascript">kontra.on('tick', () => {
// run code every frame
});</code></pre>
</section>





<section>
<h2 id="isStopped"><a href="#isStopped" class="section-link">kontra.gameLoop&#8203;.isStopped<span aria-hidden="true">#</span></a></h2>

Expand Down
85 changes: 85 additions & 0 deletions docs/api/kontra.html
Expand Up @@ -36,13 +36,20 @@ <h1>Kontra</h1>
<h2 id="toc"><a href="#toc" class="section-link">Table of Contents<span aria-hidden="true">#</span></a></h2>

<ul aria-labeledby="toc">
<li>
<ul>
<li><a href="#lifecycle">Lifecycle Events</a></li></li>
</ul>
</li>

<li>
<h3 id="properties">Properties</h3>
<ul aria-labeledby="properties">
<li><a href="#canvas">kontra&#8203;.canvas</a></li>
<li><a href="#context">kontra&#8203;.context</a></li>
<li><a href="assets">kontra&#8203;.assets</a></li>
<li><a href="keyboard">kontra&#8203;.keys</a></li>
<li><a href="plugin">kontra&#8203;.plugin</a></li>
<li><a href="pointer">kontra&#8203;.pointer</a></li>
<li><a href="store">kontra&#8203;.store</a></li>
</ul>
Expand All @@ -51,7 +58,10 @@ <h3 id="properties">Properties</h3>
<li>
<h3 id="methods">Methods</h3>
<ul aria-labeledby="methods">
<li><a href="#emit">kontra&#8203;.emit(event[, ...args])</a></li>
<li><a href="#init">kontra&#8203;.init([canvas])</a></li>
<li><a href="#off">kontra&#8203;.off(event, callback)</a></li>
<li><a href="#on">kontra&#8203;.on(event, callback)</a></li>
<li><a href="animation">kontra&#8203;.animation(properties)</a></li>
<li><a href="gameLoop">kontra&#8203;.gameLoop(properties)</a></li>
<li><a href="pool">kontra&#8203;.pool(properties)</a></li>
Expand All @@ -69,6 +79,20 @@ <h3 id="methods">Methods</h3>



<section>
<h2 id="lifecycle"><a href="#lifecycle" class="section-link">Lifecycle Events<span aria-hidden="true">#</span></a></h2>

<p>When Kontra is initialized, it will emit an <code>init</code> event.</p>

<pre><code class="language-javascript">kontra.on('init', (canvas) => {
// run code when Kontra is initialized
});</code></pre>
</section>





<section>
<h2 id="canvas"><a href="#canvas" class="section-link">kontra.canvas<span aria-hidden="true">#</span></a></h2>

Expand All @@ -91,6 +115,26 @@ <h2 id="context"><a href="#context" class="section-link">kontra.context<span ari



<section>
<h2 id="emit"><a href="#emit" class="section-link">kontra&#8203;.emit(event[, ...args])<span aria-hidden="true">#</span></a></h2>

<dl>
<dt><strong>event</strong> <em>{string}</em></dt>
<dd>The name of the event to emit.</dd>
<dt><strong>args</strong> <em>{...*}</em></dt>
<dd>Arguments passed to all callbacks.</dd>
</dl>

<p>Emit an event and run all its callbacks, passing it any arguments.</p>

<pre><code class="language-javascript">kontra.emit('myEvent', 1, 2, 'three');</code></pre>

</section>





<section>
<h2 id="init"><a href="#init" class="section-link">kontra.init([canvas])<span aria-hidden="true">#</span></a></h2>

Expand All @@ -103,6 +147,47 @@ <h2 id="init"><a href="#init" class="section-link">kontra.init([canvas])<span ar

</section>





<section>
<h2 id="off"><a href="#off" class="section-link">kontra&#8203;.off(event, callback)<span aria-hidden="true">#</span></a></h2>

<dl>
<dt><strong>event</strong> <em>{string}</em></dt>
<dd>The name of the event to emit.</dd>
<dt><strong>callback</strong> <em>{function}</em></dt>
<dd>Function callback.</dd>
</dl>

<p>Remove the callback from the event so it will no longer be run when the event is emitted.</p>

</section>





<section>
<h2 id="on"><a href="#on" class="section-link">kontra&#8203;.on(event, callback)<span aria-hidden="true">#</span></a></h2>

<dl>
<dt><strong>event</strong> <em>{string}</em></dt>
<dd>The name of the event to emit.</dd>
<dt><strong>callback</strong> <em>{function}</em></dt>
<dd>Function callback.</dd>
</dl>

<p>Add the callback to the event so it will run when the event is emitted. The callback function will be passed all arguments passed to the <a href="#emit">emit</a> function.</p>

<pre><code class="language-javascript">kontra.on('myEvent', (param1, param2, param3) => {
// ...
});

kontra.emit('myEvent', 1, 2, 'three');</code></pre>

</section>
</div>
</main>
</div>
Expand Down