Defold Intro Tutorials

April 12, 2017

1 – Kickoff with the Defold Game Engine

Having recently completed an HTML-5 game using the Phaser.io game engine, I have been researching the numerous options for cross-platform developmental tools which would enable me to migrate away from a WebView hybrid solution and focus more on native application development.  Although I was initially very excited about the potential of using a hybrid mobile app approach, the slow performance on mobile devices was definitely noticeable.   Therefore, after evaluating several alternatives (Defold, Gamemaker Studio 2, Unity, Corona, et al) –I have selected Defold as my game engine of choice — a 2D game engine from Midasplayer Technology AB, an affiliate of King.com Ltd.  Their website is:  www.defold.com   I had taken a look at several competitive alternatives, but choose […]
April 13, 2017

2 – Defold Image Procedures – Part I

Understanding how to manipulate images within any game engine certainly fall high on the list of priorities.   I’m going to be focusing on several aspects of image related processes using the Defold Game Engine — split between two postings: Part I: An overview of the Defold Building Blocks (Collections, Game Objects and Game Components); Adding images to a Defold project, and use the Atlas feature; Creating a Defold collection, adding Game Objects; Part II: Implementing Sprite Flipbooks as a means for animating sprite behaviour; Moving a Game Object within the game window; and Building a Game Object animation – focused on GO properties (e.g., the Alpha Property)   Building Blocks.   Collections of Game Objects Defold implements a hierarchical structure […]
April 13, 2017

2 – Defold Image Procedures – Part II

As a continuation of our Defold Image Processing tutorial which was started in Part I, this post will explain procedures for: (1) implementing a Sprite Flipbook to support image animation, (2) using script to move a Sprite around the game window and (3) incorporating property animation to modify game object position.   Implementing a Sprite Flipbook   Adding Animations to the Atlas The Defold Sprite FlipBook is essentially the mechanism for processing animations on a spritesheet — but using a set of Atlas image files as the source. For this example, I am going to add a series of animations to the Atlas we created in Part I. During the Part I of this tutorial, we added the individual sprite […]
April 18, 2017

3 – Select, Drag and Drop a Defold Game Object

This tutorial will expand on the basic game object procedures we reviewed in the previous posts and will explain several key procedures that will be frequently used in the development of game applications, to include: Developing a script which will invoke a Game Object ‘Factory’ – a function that will spawn additional instances of a Game Object Prototype into the application; Developing a script associated with the cursor which will enable a player to select a specific game object displayed within the game world; and Leveraging Defold features, we’ll craft a game object script which will facilitate the dragging of a game object to a new position within the game world and dropping the game object at this new position. […]
April 26, 2017

4 – Game Object Movement Techniques

Within this 4th Defold Tutorial, I’d like to work through several alternative means for moving a Game Object around the play area, to include: Use of the keyboard’s left/right/up/down arrow keys to initiate Game Object movement; Enabling a user to click (or touch) a location on the screen and have the Game Object move to that location; and Have a pre-planned path defined within the game area which the Game Object follows during its movement.   When complete, the project developed during this tutorial will look similar to the following.  You’ll be able to move the Wizard up/down/left/right using the keyboard arrow keys.   He’s constrained to the bottom portion of the game screen, and his present location is highlighted […]
May 3, 2017

5 – Preliminary Use of 2D Physics based Collisions – Part I

For this Defold Tutorial, I’d like to work through some capabilities that are similar to those found in many casual games, to include: Incorporation of Collision Objects with our Defold Game Objects as a basis for modeling the physical impacts of the effects of gravity – weight, friction and restitution (bounce); Placement of Boundaries to constrain Game Objects to the ‘world’; Leveraging the on_input feature of Defold to control cursor/game object spawning actions. Use of the Factory Component to a Game Object as the means for creating new game objects consistent with a Prototype at user selected locations; Animated surfaces affecting collision effects; Script logic driven deletion of a Game Object, and Inclusion of an explosion effect upon deleting a […]
May 17, 2017

6 – Preliminary Use of 2d Physics based Collisions – Part II

This is a continuation of the tutorial started in Part I — of this example of how to use Defold’s 2d Physics and Collision features.  In this second part, we’ll be adding: A Game Object Spawning Factory – which will create Crates at the cursor position when the mouse button is clicked; and An Explosion for each Crate that hits the floor of the game window – deleting the Game Object. Here we go…..   Creating a Crate Game Object Spawning Factory   The initial step in creating a factory for this project will be to develop a Game Object Prototype related to a Crate.  Within the Project Explorer, create a new Game Object named ‘cratePrototype’.  You can do this […]
May 26, 2017

7 – ConvexShaped Collision Objects

In developing the simple physics example explained in tutorials # 5 & 6, we learned that collision objects can use either a box, capsule or sphere shape.   So…what if we want to incorporate a triangle shaped game object? As an example, the triangle image below is 140 pixels wide, and 70 pixels in height.   To create a Collision Object Shape which matches this polygon, the simplest approach is to create a convex hull shape using data within a .convexshape file.   Within this file, we provide the vertices of the polygon as shown below. At this point, we’re ready to extend our previous example to include a triangle shaped wooden block as one of the game objects created […]
May 30, 2017

8 – Animated GUI Nodes

In thinking about all the design elements that are required to develop a viable Defold game, I think having an attractive and functional Graphical User Interface (GUI) is definitely high on the list.   In this tutorial, I’m going to describe how to animate components of a menu; in future tutorials, we’ll expand on that concept with other Defold GUI features. The end result for this tutorial is shown in the following iframe — where animated buttons are displayed (varying both size and opacity) to provide a user with two level options.  Upon pressing and releasing a button, a popup is displayed to highlight which level was selected, with an ‘Active Level’ text field at the top of the game […]
February 8, 2018

9 – Intro to Levels, Messages and Menus

Tutorial Introduction This next Defold Introductory Tutorial is focused on the concept of a Game Level.   This is an important feature that enables the game developer to have separate scenes for introductions, game instructions, progressive game levels, etc.  Key features explained within this tutorial include: Game Levels using Collections – based on the manner in which Defold organizes game objects into collections….in this example, there will be a main level, a Level 1 and a Level 2. Collection Proxies – this mechanism enables the game developer to aggregate game objects across multiple levels, and use Lua Scripting to dynamically manage these collections. Defold Messaging – this new tutorial will explain how to use messaging to exchange key game control […]