Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.

public final class SheetImport

  1. Object
  2. SheetImport

Imports a character drawn in Aseprite (or any tool that writes its sheet format, such as LibreSprite or TexturePacker’s “JSON (Array)”) as a SpriteSheet and an ActorAnimator, so hand-drawn art drops into a PlatformArt without any code per animation.

Export with File > Export Sprite Sheet: any layout, trim off, and JSON Data with tags. Name each tag after the state it animates – idle, walk, run, jump, fall, crouch, crawl, climb, wall, dash, glide, jetpack, swim, grip, push, hurt or dead (the MovementState names work too). Frame durations become the clip’s speed; a tag set to ping-pong plays forwards then back; jump, hurt and dead play once, everything else loops. States with no tag fall back as ActorAnimator always does (run to walk, fall to jump, …).

import com.codename1.gaming.platformer.view.*;
import com.codename1.io.Util;

Image sheetImage = Image.createImage(Display.getInstance().getResourceAsStream(null, "/hero.png"));
String jsonText = Util.readToString(Display.getInstance().getResourceAsStream(null, "/hero.json"));
SheetImport hero = SheetImport.read(sheetImage, jsonText);
// a PlatformArt then answers sheet(actor) with hero.getSheet()
// and animator(actor) with hero.getAnimator()

Methods

public static SheetImport read(Image image, String json)Reads a sheet and its JSON.
public static MovementState stateFor(String tag)The tag name’s state, or null for a tag that is no state (an attack, a victory pose), which is still in getClips().
public SpriteSheet getSheet()The sheet, cut into frames.
public ActorAnimator getAnimator()The animator, with a clip for every tag that names a state.
public Map<String, ActorAnimator.Clip> getClips()Every clip by tag name, including tags that are not states.

Inherited methods

Method details

read

public static SheetImport read(Image image, String json)
Reads a sheet and its JSON.

Parameters

image Image
the exported sheet image
json String
the exported JSON

Returns

the sheet, its animator and its clips by tag name

Throws

IllegalArgumentException
for a trimmed sheet, frames of different sizes, or JSON that is not a sprite sheet

stateFor

public static MovementState stateFor(String tag)
The tag name’s state, or null for a tag that is no state (an attack, a victory pose), which is still in getClips().

Parameters

tag String
a tag name

Returns

the state, or null

getSheet

public SpriteSheet getSheet()
The sheet, cut into frames.

Returns

the sheet

getAnimator

public ActorAnimator getAnimator()
The animator, with a clip for every tag that names a state.

Returns

the animator

getClips

public Map<String, ActorAnimator.Clip> getClips()
Every clip by tag name, including tags that are not states.

Returns

the live map