This starter project is designed to let you implement the tutorial Making your first Phaser 3 Game using Visual Studio Code.
Changes from the original tutorial files:
-
The code now lives entirely in
index.js
. This is the empty version - a fully completed version with the working code is available -
The scene has been implemented as a class. This allows the Intellisense to work better. It also means you don't need to declare the variables, you can simply create them as instance variables with
this.platforms = ..
when you first use them. -
I have added type definitions, a jsconfig.json, and the
//@ts-check
command so that Visual Studio Code will give detailed warnings and feedback based on the Phaser.js API and stricter javascript rules. Delete the//@ts-check
command if you don't want type checking, and only want the intellisense popus.
These instructions work as of April 6, 2021.
-
Download the latest type definition files from https://github.com/photonstorm/phaser/tree/master/types
-
Put them in a folder in your root project directory called 'typings'
-
Create a file called
jsconfig.json
in your root directory if it does not exist, and simply add the blank object{}
. (See https://code.visualstudio.com/docs/languages/jsconfig) for more details about this file you may need for more advanced projects.) -
Add the line
//@ts-check
as the first line in all of your javascript files. (you can leave this out for intellisense without type checking) -
Implement scenes using classes, even if you're only using one scene. If you follow the really simple tutorials that don't do that, VS Code won't be able to figure out the types.