Example: System to Print Custom Formatted Debug Strings to the Screen and Browser Log

1

Stats

144 visits, 163 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 28 Apr, 2024.

Construct's event sheet logic is powerful and fun to use, but it can be difficult to debug due to its breakpoint restrictions. One useful tool is the ability to log messages in the web browser console, but this requires opening the console after launching the project, and it can be difficult to monitor what's happening in your game while also keeping an eye on the web console. The attached example shows a way to log messages directly to the screen (and optionally the browser log as well) so you can get immediate visual feedback about the state of your game without looking away from it. This is similar to the PrintString method used by Unreal and other engines.

The system is fairly modular and integrating it into your own projects should be straightforward. The core system consists of the PrintStringSystemObjects layout, the PrintStringSystemEvents event sheet, the PrintDisplay text object, the PrintStringArray, and the PrintStringMessage template object. Your project will also need the Browser plugin unless you first remove the browser logging events from the Print String system. Copy these core objects and the event sheet into your project and include the PrintStringSystemEvents as-needed in your own event sheets. Finally, place an instance of the PrintDisplay object in your layout and use its custom actions to print messages, clear the display, etc. A layout can have as many PrintDisplay objects as you like.

The example layouts and event sheets are only included to show how the system can be used and aren't needed otherwise.

I've attempted to comment the project thoroughly enough that it should be clear for an intermediate Construct user to understand how things work, but feel free to ask questions in the comments or message me directly if you have any problems.

  • 0 Comments

Want to leave a comment? Login or Register an account!