Add docs for tween_nokaboom.js
This commit is contained in:
parent
7c1c4f7e0e
commit
018ec698d6
1 changed files with 32 additions and 0 deletions
32
README.md
32
README.md
|
@ -9,6 +9,19 @@ A tween library for Kaboom that allows easy usage of tweens. It also comes with
|
||||||
### `easingpackage.js`
|
### `easingpackage.js`
|
||||||
- **Requires** a JavaScript version that supports ES6 functionality
|
- **Requires** a JavaScript version that supports ES6 functionality
|
||||||
- **Can be used with** Kaboom, any version
|
- **Can be used with** Kaboom, any version
|
||||||
|
## Differences between `tween.js` and `tween_nokaboom.js`
|
||||||
|
|
||||||
|
### `tween.js`
|
||||||
|
- Smaller file size, but depends heavily on Kaboom functions
|
||||||
|
- Perfect for Kaboom games
|
||||||
|
- Uses `onUpdate()`, `lerp()`, and `time()`
|
||||||
|
|
||||||
|
### `tween_nokaboom.js`
|
||||||
|
- Bigger file size, but not dependent on Kaboom at all
|
||||||
|
- Uses `performance.now()`, a very precise and lightweight time getter function
|
||||||
|
- Do not use while making a Kaboom game, it would be pointless! Use for normal JS Canvas games instead.
|
||||||
|
- Uses `Window.requestAnimationFrame()`
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
`tween()` - Creates a tween to animate properties of an object.
|
`tween()` - Creates a tween to animate properties of an object.
|
||||||
|
@ -51,6 +64,7 @@ A tween library for Kaboom that allows easy usage of tweens. It also comes with
|
||||||
- private `__NOOP: Function`
|
- private `__NOOP: Function`
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
`tween.js`
|
||||||
```js
|
```js
|
||||||
import { KBTween } from ".../tween.js";
|
import { KBTween } from ".../tween.js";
|
||||||
import { easings } from ".../easingpackage.js";
|
import { easings } from ".../easingpackage.js";
|
||||||
|
@ -88,3 +102,21 @@ twnlib.tween(bean.color, [ "g", "r" ], {
|
||||||
type: tweentypes.PINGPONG
|
type: tweentypes.PINGPONG
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
`tween_nokaboom.js`
|
||||||
|
```html
|
||||||
|
<p>Points: <span id="number">0</span></p>
|
||||||
|
<script type="module" src="...js"></script>
|
||||||
|
```
|
||||||
|
```js
|
||||||
|
import { KBTween } from ".../tween_nokaboom.js";
|
||||||
|
import { easings } from ".../easingpackage.js";
|
||||||
|
|
||||||
|
var twnlib = KBTween();
|
||||||
|
|
||||||
|
twnlib.tween(document.getElementById("number"), ["innerHTML"], {
|
||||||
|
from: 0,
|
||||||
|
to: 1000,
|
||||||
|
time: 10,
|
||||||
|
type: twnlib.tweentypes.NORMAL
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in a new issue