public class AssetDef
- Object
- AssetDef
The definition of one placeable asset in an AssetPack: the template a placed
GameElement references through its GameElement#getAssetId().
It mirrors an entry in the editor’s asset catalog – an id, a display name, a
#getKind() (a Kind#TILE painted into a grid cell vs a freely placed
Kind#ACTOR), a natural pixel size, a base #getColor() (used to render a
placeholder until the real art loads), whether the level may hold more than one
(#isUnique()), the default authoring properties copied onto a freshly placed
element, and – the part that makes it a real asset – a #getType() and a
#getSource() art file:
Type#IMAGE– a single static image (sourceis a PNG/JPG path), realized as acom.codename1.gaming.Sprite.Type#SHEET– a sprite sheet: an image of equal frames in a grid (#getFrameWidth()x#getFrameHeight(),#getFps()), realized as an animatedcom.codename1.gaming.AnimatedSprite.Type#MESH– a 3D mesh (sourceis a glTF/glb path), realized as acom.codename1.gaming.Modelin a 3D level.
Nested types
enum AssetDef.Kind | How an asset is placed: painted into a grid cell, or freely positioned. |
enum AssetDef.Type | The art format of an asset, which decides what it is realized into. |
Constructors
public AssetDef() | |
public AssetDef(String id, AssetDef.Kind kind, int color, int width, int height) |
Methods
Inherited methods
Constructor details
AssetDef
public AssetDef()AssetDef
public AssetDef(String id, AssetDef.Kind kind, int color, int width, int height)Method details
getId
public String getId()setId
public AssetDef setId(String id)getName
public String getName()setName
public AssetDef setName(String name)getKind
public AssetDef.Kind getKind()How this asset is placed (
Kind#TILE vs Kind#ACTOR).setKind
public AssetDef setKind(AssetDef.Kind kind)isTile
public boolean isTile()getWidth
public int getWidth()getHeight
public int getHeight()setSize
public AssetDef setSize(int width, int height)getColor
public int getColor()setColor
public AssetDef setColor(int color)isUnique
public boolean isUnique()setUnique
public AssetDef setUnique(boolean unique)getSource
public String getSource()setSource
public AssetDef setSource(String source)getType
public AssetDef.Type getType()The art format:
Type#IMAGE, Type#SHEET or Type#MESH.setType
public AssetDef setType(AssetDef.Type type)isSheet
public boolean isSheet()isMesh
public boolean isMesh()getFrameWidth
public int getFrameWidth()Sprite-sheet frame width in pixels (0 = the whole image is one frame).
getFrameHeight
public int getFrameHeight()Sprite-sheet frame height in pixels (0 = the whole image is one frame).
getFrameCount
public int getFrameCount()Number of frames to play (0 = every frame in the sheet).
getFps
public double getFps()Sprite-sheet playback rate in frames per second.
setSheet
public AssetDef setSheet(int frameWidth, int frameHeight, int frameCount, double fps)Marks this asset as a sprite sheet with the given frame grid and rate.
defaultProperties
public Map<String, Object> defaultProperties()The default authoring properties copied onto a newly placed element of this
asset (a coin’s
value, a player’s lives, …).putDefault
public AssetDef putDefault(String key, Object value)