Phaser Editor is focused mainly on provide design tools. You can code your game using advanced third-party editors.
You can use any coding editor, but we recommend Visual Studio Code. Actually, the projects generated by the IDE are full compatible with that editor and includes the configuration files.
However, we included basic code editors inside Phaser Editor so you can do a quick preview or modification of the code.
These editors are based based in the Monaco editor, and have a decent amount of features, especially for JavaScript development. If you are using an advanced toolchain for coding your game, like using a bundler, we strongly recommend you to use Visual Studio Code.
Phaser Editor runs on the desktop or in the cloud, and you can find excelent code editors in both environments. Especially, those editors based on Visual Studio Code. Learn how Phaser Editor integrates with Visual Studio Code in the next section.
Visual Studio Code compatibility
The Visual Studio Code editor is prefect for writing the code of the Phaser Editor games. First, t is extremely popular and powerful. Second, cause the projects created by Phaser Editor contains the files needed by Visual Studio Code to provide a good coding experience with Phaser.
Project structure
The JavaScript project templates include these files:
- The file
lib/phaser.js
. It is the Phaser runtime. - The Phaser type definition files:
types/phaser.d.ts
andtypes/matter.d.ts
. Those files are provided by Phaser and are used by the Visual Studio Code to “understand” the Phaser API. - The project configuration file:
jsconfig.json
. If it is a TypeScript project, then it includes the tsconfig.json file, instead of thejsconfig.json
file.
Code Server
If you are using a remote instance of Phaser Editor, you can try Code Server. It allows to run VS Code in the same Phaser Editor server and edit the game code in your local browser.
Also, you can use cloud services like GitHub Codespace or Gitpod. In both cases you can install Phaser Editor Core as a project dependency and run it alongside with VS Code.
Visual Studio Code & Phaser Editor integration
You can launch Visual Studio Code from Phaser Editor. The command is Open Visual Studio Code (Ctrl+Alt+U)
. It is a smart command, so it addition to open the project in Visual Studio Code, it finds the right file to open in Visual Studio Code.
If the file in Phaser Editor is a scene, it will open the scene’s source file. If the current file is the User Components editor, it will open the selected component's source file.
This command is fundamental to quickly navigate between the design tools and the code editor. You can trigger it from the main toolbar: