Defold Examples
These are per-example files generated for LLM usage.
Animation
Basics
- Message passing - This example shows how to communicate between two script components in two separate game objects
- Parent/child - This example shows how to child a game object to a parent
- Random numbers - This example shows how to generate pseudo-random numbers in Defold using built-in math API
- Z-order - This example shows how to put sprites in front and behind of eachother
Collection
- Proxy - This example shows how to use collection proxies to load and unload collections
- Splash - This example shows how to use collection proxies to show a splash screen while loading a game menu
- Time-step - This example shows how to speed up or slow down animations in a collection proxy by changing the time step of the collection proxy
Debug
- Physics debug - This example allows you to toggle physics debug visualization as well as changing the time step so the simulation runs at one tenth of the speed
- Visual profiler - This example shows the on-screen profiler
Factory
- Dynamic factories - This example shows how to change the prototype game object used by a factory component
- Shoot bullets - This example shows how to dynamically spawn bullet game objects using a factory component
- Spawn enemies with central management - This example shows how to spawn enemy game objects using a factory component and use a central manager to control movement and behavior of all enemies
- Spawn enemies with script properties - This example shows how to spawn enemy game objects using a factory component with different properties
- Spawn game object - This example shows how to dynamically spawn game objects with a factory component
File
- Load JSON data - This example shows how to load json data using sys
- Save and Load - This example shows how to save and load data using sys
Gui
- Button - A GUI box node with an image texture and a script to make it act as a button
- Drag - This example shows how to drag a GUI box node
- Get and set a gui font resource - This example shows how to get and set a font resource on a gui component
- Get and set a gui material resource - This example shows how to get and set a material resource on a gui component
- Get and set a gui texture resource - This example shows how to get and set a texture resource on a gui component
- GUI color - This example shows how change the color of GUI nodes at run-time
- GUI progress indicators - This example shows how to create various types of progress indicators
- Health Bar - This example demonstrates how to add different health bars
- Layouts - This example demonstrates the use of layouts
- Load texture - This example shows how to load and set a dynamic texture on a gui box node
- Localization (RTL/LTR) - This example demonstrates how to handle localization in games, Unicode text layout, RTL rendering, and runtime font switching for localization
- Pointer over - A GUI box node with an image texture and a script that react when pointer over this node
- Slice-9 - This example demonstrates slice-9 scaling gui box node
- Stencil - A GUI box node with “Clipping mode” set to “STENCIL”
- 8 ways movement - A very simple 8 ways movement setup with a single game object and a script that listens to input and updates the game object position accordingly
- Down duration - Listens to input trigger “touch” and count mouse down duration in update method
- Entity Picking - This example demonstrates how to pick a game object from the 3D scene
- Mouse and touch events - Shows how to read mouse/touch movement and mouse/touch button state
- Text input - Listens to text input trigger “type” and modifies the game object label with the alien’s speech according to input
Material
- Billboarding - This example shows how to make sprites and particle sprites face the camera using a custom vertex shader
- Custom Sprite - This example demonstrates a simple way to create and apply a custom sprite shader for changing colors and customizing an outline
- Noise shader - This example shows how to use a noise function to generate clouds, smoke or similar effect using a shader
- Repeating Background - Create a scrolling background using a repeating texture on a model quad
- Screenspace - This example shows how to create a custom material with two textures that blend together to create a pattern effect using screen space coordinates
- Sprite local UV - This example shows how to get local UV coordinates of a sprite regardless of sprite size
- Sprite Vertex Color Attribute - This example shows how to set and animate a vertex attribute
- Unlit - This example demonstrates how to create and apply an custom non-lit material to a 3D model
- UV Gradient - This example shows how to apply a basic shader to a full screen quad
- Wave Background - Shows how to use a Time shader constant to achieve a moving wave effect
Mesh
- Mesh - This example shows how to create a basic mesh component in the shape of a triangle
- Textured Mesh - This example shows how to create a textured mesh component in the shape of a rectangle
Model
- AABB - This example demonstrates how to use the `model
- Character - This example shows how to view and play skeletal animations on a glTF model
- Cubemap Reflection - This example shows how to use a cubemap to draw environment reflections on a model
- GLTF - This example demonstrates how to use a glTF model
- GPU Skinning - This example demonstrates GPU skinning
- Model Vertex Color - This example demonstrates how to apply a vertex color shader using exported attributes from a 3D model
- Skybox - This example shows how to create a skybox using a cubemap texture
Movement
- First-person 3D camera and movement - Control a first-person camera using WASD and mouse to look with cursor lock
- Follow input - This example shows how to make a game object continuously follow the mouse
- Look at - This example shows how to rotate a game object to look at the mouse cursor
- Look rotation - This example shows how to rotate a game object to look at the object in 3D space
- Move forward - This example shows how to move a game object in the direction it is rotated/facing
- Move to target - This example shows how to make a game object move to the position the user clicks
- Movement speed - This example shows how to move a game object with accelerating speed
- Moving game object - This example shows how to move a game object
Particles
- Modifiers - This example shows particle effect modifiers
- Particle effect - This example shows a simple particle effect
- Particle Effect Emission Space - This example demonstrates the difference between local and world particle emission spaces
- Particle effect example - fire and smoke - This example shows a simple particle effect for imitating fire and smoke using two emitters and 3 modifiers in a single particlefx component
- ParticleFX - Confetti - This example shows a simple particle effect to imitate confetti with multiple emitters and global multipliers for all of them
- ParticleFX - Fountain - Start Delay - This example shows how the Start Delay emitter property can be used to sequence two emitters inside a single ParticleFX and create a simple fountain effect
- ParticleFX emitter properties - This example shows how to get and set ParticleFX emitter image, animation, and material at runtime
- Spawning Fireworks ParticleFX - This example shows how to spawn firework rockets with separate trail and burst particle effects, including a small dip before the burst
Physics
- Apply force - This example demonstrates how to apply directional force to all dynamic blocks on touch/click and draws debug direction lines
- Dynamic physics - This example shows a simple setup with dynamic physics objects
- Fixed timestep interpolation - This example shows how to smooth physics motion in fixed update mode by interpolating a visual sprite while keeping the physics body fixed-step
- Hinge joint physics - This example shows a simple setup with a dynamic body physics object and two dynamic wheel physics object joined together with a joint of type “hinge”
- Kinematic physics - This example shows a simple setup with a kinematic physics objects
- Knockback - This example shows how to create a knockback effect when hit
- Pendulum physics - This example shows a simple setup with a static pivot and two dynamic weights - physics objects joined together with a joint of type “fixed” and “spring”
- Raycast - This example shows how to use physics raycasts to detect collisions along a straight line from a start point to an end point
- Trigger - This example shows how a physics trigger is used to trigger an event
Render
- Camera - This example shows how to use a camera component and have it follow a game object
- Orbit Camera - This example demonstrates how to create script to control a 3D camera with the mouse
- Orthographic Zoom - This example shows how to zoom an orthographic camera in and out by changing Orthographic Zoom while the camera is in Fixed mode
- Post-processing - This example shows how to apply a post-processing effect by drawing to a render target and then to a fullscreen quad using a post processing shader
- Screen to World - This example shows how to convert from screen to world coordinates while using a camera
- World to Screen - This example demonstrates how to convert 3D world coordinates to 2D screen coordinates using camera transformations
Resource
- Create atlas - This example shows how to create an atlas with two images and use it on a sprite and in a gui
- Modify atlas - This example shows how to replace an image in an atlas
Sound
- Fade In-Out - This example shows how to make Fade-In and fade Fade-Out music
- Get and set sound - This example shows how to change which sound a sound component plays
- Music - This example shows how to play a piece of music, stored as an
- Panning - This example demonstrates how to pan a sound effect according to a GO’s(game object) position on the screen
Sprite
- Bunnymark - This is a performance test for sprites
- Change sprite image - This example shows how to change the image of a sprite
- Flip - This example demonstrates flipping a sprite animation vertically and horizontally
- Multiple Sprite Samplers - This example shows how to sample from more than one image when drawing a sprite
- Sprite cursor - This example shows how to use the sprite animation cursor and frame count to manually select a specific frame
- Sprite size - This example shows how to get the size of a sprite at run-time
- Sprite tint - This example shows how tint a sprite at run-time
- Texture scrolling - This example shows how scroll the texture in the runtime using Texture Transform 2D Vertex Attribute, without using the sprite in the world space
Tilemap
Timer
- Cancel timer example - This example shows how to create timer and cancel it anytime, using built-in timer API
- Repeating timer example - This example shows how to create timer that repeats endlessly every second
- Trigger timer example - This example shows how to create timer that triggers counting every 1s and can be triggered manually and asynchronously as a reaction to user input