Importing 2D graphics

Defold supports many kinds of visual components frequently used in 2D games. You can use Defold to create static and animated sprites, UI components, particle effects, tile maps and bitmap fonts. Before you can create any of these visual components you need to import image files with the graphics that you wish to use. To import image files you simply drag the files from the file system on your computer and drop them in an appropriate place in the Defold editor Assets pane.

Use PNG or JPEG images for atlases and tile sources. KTX2 source textures can also be imported for use as model textures; see below.

KTX2 textures

Import a standalone .ktx2 file by dragging it into the Assets pane, then assign it to a Model component’s material texture field. glTF and GLB models can also reference external KTX2 files or contain embedded KTX2 images. Atlas, tile-source and cubemap-face inputs continue to use their existing image formats.

Supported KTX2 inputs are 2D textures using ETC1S/BasisLZ, UASTC, BC7, or 8-bit R/RG/RGB/RGBA UNORM or sRGB data. KTX2 arrays, cubemaps, volumes and HDR textures are not supported. KTX2 is processed at build time into Defold’s .texturec resources; the runtime does not read KTX2 containers.

Open a KTX2 asset to inspect its source format, dimensions, color space, alpha metadata and mip levels. The Outline lets you select individual authored mip levels. These show the source images even if a texture profile resizes the compiled texture or disables its mipmaps.

Use texture profiles to choose between keeping the source format and converting it to other formats. Choose output formats supported by your target devices. Recompressing an already lossy source can reduce quality further, including when Keep KTX2 Format needs to re-encode after image processing.

Creating Defold assets

When the images are imported into Defold they can be used to create Defold specific assets:

Atlas
An atlas contains a list of separate images files, which are automatically combined into a larger texture image. Atlases can contain still images and Animation Groups, sets of images that together form a flipbook animation.

Learn more about the atlas resource in the Atlas manual.

Tile Source
A tile source references an image file that is already made out to consist of smaller sub-images ordered on a uniform grid. Another term commonly used for this type of compound image is sprite sheet. Tile sources can contain flipbook animations, defined by the first and last tile for the animation. It is also possible to use an image to automatically attach collision shapes to tiles.

Learn more about the tile source resource in the Tile source manual.

Bitmap Font
A bitmap font has its glyphs in a PNG font sheet. These types of fonts provide no performance improvement from fonts generated from TrueType or OpenType font files, but can include arbitrary graphics, coloring and shadows right in the image.

Learn more about bitmap fonts in the Fonts manual.

Using Defold assets

When you have converted the images into Atlas and Tile Source files you can use these to create several different kinds of visual components:

A sprite is either a static image or flipbook animation that is displayed on screen.

Learn more about sprites in the Sprite manual.

Tile map
A tilemap component pieces together a map from tiles (image and collision shapes) that come from a tile source. Tile maps cannot use atlas sources.

Learn more about tilemaps in the Tilemap manual.

Particle fx
Particles that are spawned from a particle emitter consist of a still image or a flipbook animation from an atlas or tile source.

Learn more about particle effects in the Particle fx manual.

GUI
GUI box nodes and pie nodes can use still images and flipbook animations from atlases and tile sources.

Learn more about GUIs in the GUI manual.