Skip to content
bapquad edited this page Feb 28, 2022 · 2 revisions

This guide show you how to make a static sprite and anime sprite with CaremJS.

Create a static sprite

You can create a static sprite with StaticSprite class.

let fish = new Carem.StaticSprite(asset, 0, 0, 201, 120, scene);

The static sprite works with physics and world limit default.

fish.SetGravity(2.0);
fish.EnableGravity();

Create an anime sprite

The anime sprite need a image with frames of animation like as below figure.

image

After loaded completely, you can assign the image into the anime sprite.

let fish = new Carem.AnimeSprite(asset, 198, 114, scene);

You should create the action constants for use actions

this.actions = [0, 1];
fish.SetAction(this.actions[1]);

With the 0 value, it use first row of frames.

Clone this wiki locally