Search the Community
Showing results for tags 'tern-phaser'.
-
Hi there everyone, As someone asked on the phaser slack, here's a guide to get auto completion for Phaser in Atom on Windows. It is powered by Angelo's tern-phaser plugin. Installing tern This first part explains how to get npm, install tern and the tern-phaser plugin. The first thing that you need to ensure is that you have Node.js installed on your computer. You can download it on https://nodejs.org/en/. This will give you access to npm as well, a handy package manager for js libraries and plugins. It allows you to download install all sorts of packages from the command prompt. Once Node.js has finished installing, we have a few commands to call from the command prompt. On windows, you can access the command line need to press the Windows R key combination, type "cmd" and press enter. Then we need to install a few packages. First, there is tern, the JS analyzer that the tern-phaser plugin uses. In the command line tool, type "npm install tern" and press enter. Npm will take care of the install for you, it will just take a moment. We then need the tern-phaser plugin to be installed where the tern package has been put. You can let windows find the folder for you by typing "npm install -g tern-phaser" in the command prompt and pressing enter. The manual route If AND ONLY IF the automatic install of tern-phaser doesn't work, you'll have to go navigate to the tern install folder manually from the command prompt. To change the folder the command prompt is in, you need to type cd (current directory) followed by the path you want to reach. By default, tern should be installed to C:\Users\YourName\node_modules and tern-phaser should go into your global modules folder, into C:\Users\YourName\AppData\Roaming\npm\node_modules. In the command prompt, you then have to enter "cd C:\Users\YourName\AppData\Roaming\npm\node_modules". Note that you can copy the path from windows and paste it in the command prompt using the right mouse button (Ctrl V doesn't work by default). Right click on the command line window to paste text. Once you got to the right folder, just type npm "install tern-phaser" and press enter. Without -g, the command installs the tern-phaser package in the folder you're currently in. Using tern-phaser with Atom Now, you have both tern and tern-phaser installed on your computer. Let's move to setting up atom to work with tern. There is no native integration of tern in atom. However, there is a plugin called atom-ternjs that works like a charm. We can install the package from the command line as well. Either close and reopen the command prompt or navigate back to your root folder with the following command: "cd C:\Users\YourName". Then, to call the Atom Package Manager, you need to use the apm command. Type "apm install atom-ternjs" and press enter. This will add this package to atom for you. To use tern with your project, you just need to have a tern configuration file. Atom-ternjs can create a basic config file for you. In Atom, you first need to have at least one javascript file loaded. Then, go to packages -> Atom ternjs -> Configure project You can set some parameters in the newly opened tab and click on save and restart server. This will create a new .tern-project file in your project folder. We still need to tell it to use the phaser plugin. You just have to add "phaser" in the plugins section. Here's the content of my .tern-project file: { "ecmaVersion": 5, "libs": ["browser"], "plugins": { "phaser": {} } } Save your file, and then go to package -> Atom Ternjs -> Restart server. If you don't get any error, you're good to go! Note that having a phaser.js file next to your .tern-project file can prevent tern-phaser from working - in which case you'll get a series of errors in Atom.
- 17 replies