💻

JavaScript in GDevelop

Sep 17, 2025

Overview

This lecture explains how JavaScript can be used in the GDevelop no-code game engine, both directly in events and within extensions, to expand game functionality.

Using JavaScript in GDevelop Events

  • JavaScript is supported in GDevelop, allowing for custom logic and control.
  • Normally, actions like moving an object can be done with the no-code event system.
  • A JavaScript code block can be added to events by right-clicking and selecting "Add JavaScript code".
  • In JavaScript, object methods can set forces, e.g., applying a force of 150 pixels/sec to move an object right.
  • Debugging is possible using developer tools to check for errors if the code does not work.
  • Errors like a typo or missing context (e.g., incorrect object references) can cause issues such as a black screen.

Event System vs JavaScript

  • No-code actions and conditions are translated into JavaScript behind the scenes when the game runs.
  • Both approaches (no-code and JavaScript) can achieve the same results for many simple tasks.
  • JavaScript provides more flexibility for complex logic or features not available in the no-code system.

Using JavaScript in Extensions

  • Extensions allow encapsulating reusable features, written either in JavaScript or using the no-code system.
  • Extensions can be created or installed via the project manager.
  • JavaScript is often used in extensions when specific functionality (like Gamepad support) isn’t available in no-code actions and conditions.
  • Installed extensions add new actions and conditions to the event sheet, expanding the engine’s capabilities.
  • Writing reusable code in extensions helps keep features organized and easily shareable between projects.

Key Terms & Definitions

  • GDevelop — a no-code, open-source game engine for creating games without traditional programming.
  • Event Sheet — area where game logic is created in GDevelop using events, actions, and conditions.
  • JavaScript Block — a section in GDevelop where custom JavaScript code can be written.
  • Extension — a modular add-on that provides new features or logic, sometimes written in JavaScript.
  • Force — a method to move objects in GDevelop, typically described in pixels per second.

Action Items / Next Steps

  • Experiment with adding JavaScript blocks to events in GDevelop.
  • Explore or create extensions in your project to organize advanced features.
  • Review available learning resources for JavaScript in GDevelop (as linked in lecture description).