Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public interface EntityFactory

Creates a game’s own entity types from level JSON, for types LevelData does not know. Pass one to LevelData#createWorld(long, EntityFactory).

Methods

public abstract LevelEntity create(String id, String type, int x, int y, int tileSize, Map<String, Object> spec)Creates an entity, or declines.

Method details

create

public abstract LevelEntity create(String id, String type, int x, int y, int tileSize, Map<String, Object> spec)
Creates an entity, or declines.

Parameters

id String
the id to give it
type String
the type field
x int
the left edge of its cell, fixed point
y int
the top edge of its cell, fixed point
tileSize int
the tile size, fixed point
spec Map<String, Object>
the whole JSON object, for its other fields

Returns

the entity, or null if the type is not this factory’s