Class AssetDef
java.lang.Object
com.codename1.gaming.level.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 Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumHow an asset is placed: painted into a grid cell, or freely positioned.static enumThe art format of an asset, which decides what it is realized into. -
Constructor Summary
ConstructorsConstructorDescriptionAssetDef()AssetDef(String id, AssetDef.Kind kind, int color, int width, int height) -
Method Summary
Modifier and TypeMethodDescriptionThe default authoring properties copied onto a newly placed element of this asset (a coin'svalue, a player'slives, ...).intgetColor()doublegetFps()Sprite-sheet playback rate in frames per second.intNumber of frames to play (0 = every frame in the sheet).intSprite-sheet frame height in pixels (0 = the whole image is one frame).intSprite-sheet frame width in pixels (0 = the whole image is one frame).intgetId()getKind()How this asset is placed (Kind#TILEvsKind#ACTOR).getName()getType()The art format:Type#IMAGE,Type#SHEETorType#MESH.intgetWidth()booleanisMesh()booleanisSheet()booleanisTile()booleanisUnique()putDefault(String key, Object value) setColor(int color) setKind(AssetDef.Kind kind) setSheet(int frameWidth, int frameHeight, int frameCount, double fps) Marks this asset as a sprite sheet with the given frame grid and rate.setSize(int width, int height) setType(AssetDef.Type type) setUnique(boolean unique)
-
Constructor Details
-
AssetDef
public AssetDef() -
AssetDef
-
-
Method Details
-
getId
-
setId
-
getName
-
setName
-
getKind
How this asset is placed (Kind#TILEvsKind#ACTOR). -
setKind
-
isTile
public boolean isTile() -
getWidth
public int getWidth() -
getHeight
public int getHeight() -
setSize
-
getColor
public int getColor() -
setColor
-
isUnique
public boolean isUnique() -
setUnique
-
getSource
-
setSource
-
getType
The art format:Type#IMAGE,Type#SHEETorType#MESH. -
setType
-
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
Marks this asset as a sprite sheet with the given frame grid and rate. -
defaultProperties
-
putDefault
-