whale-pyxel¶
Pyxel Edit support module. It provides routines for loading sprite sheets and animations created with Pyxel Edit.
const whl = require("whale-core");
const pyxel = require("whale-pyxel");
// ...
var pyxelBuffer = whl.fs.openFile("whale.pyxel").read();
var pyxelDoc = pyxel.Doc(pyxelBuffer);
var bubbleSprite = pyxelDoc.animation("bubble").frameAt(0).sprite.clone();
var canvas = new whl.Canvas(/* ... */);
// Set sprite position to (0, 0).
bubbleSprite.transform = whl.translate(new whl.Vec2(0, 0));
canvas.draw(bubbleSprite);
- class whale-pyxel.Animation()¶
Represents a sequence of frames.
Instances of this class are created by
Doc()in the loading process. They cannot be created directly.- Animation.frame(index)¶
- Arguments:
index (
Number()) – Frame index.
- Return type:
Returns an frame under a given index.
- Animation.frameCount()¶
- Return type:
Number
Returns number of frames.
- Animation.frameAt(time)¶
- Arguments:
time (
Number()) – Time in seconds.
- Return type:
Returns a frame at a specified time.
Time gets wrapped around if it is longer than the length of the animation. It makes it easier to play looping animations.
- class whale-pyxel.Doc(buffer)¶
- Arguments:
buffer (
whale-core.Buffer()) – Buffer with contents of Pyxel Edit document file.
Represents Pyxel Edit document. It contains a sprite sheet image and a list of animations.
- Doc.image()¶
- Return type:
Returns a sprite sheet image.
- Doc.animation(name)¶
- Arguments:
name (
String()) – Animation name.
- Return type:
Returns an animation by its name.
- class whale-pyxel.Frame(duration, sprite)¶
- Arguments:
duration (
Number()) – Duration in seconds.sprite (
whale-core.Sprite()) – Frame sprite.
Represents an animation frame.
- Frame.duration¶
- Type:
Number
- Frame.sprite¶
- Type: