Sign in to follow this  
legan

Problem with Phaser and Typescript IntelliSense in VS

Recommended Posts

Hi, I've been using Phaser with Notepad++ until now but I decided to try Visual Studio with Typescript (everyone praised the IntelliSense, so I thought it would be good to test it myself). I'm a completely noob so maybe I screwed up in something pretty obvious, but the IntelliSense is not working.

 

 

jql5e1.png

 

The strange thing is that it worked at first... but it doesn't work now. I tried with the references to the phaser files but the problem persists. Is there something I'm missing?

Share this post


Link to post
Share on other sites

I would guess it doesn't know what type this.enemy is as you haven't defined it.

enemy: Phaser.Sprite;

Also you seem to be just renaming your .js files to .ts. Which means you are doing things that are not required by ts. In ts you just create a class, optionally in a module, that has properties and methods and are not concerned with the js prototype syntax mess.

Share this post


Link to post
Share on other sites

Yes, _oOo_ is right - VS will not help you, if you do not tell it what kind of object your enemy is. You can copy your JS code into TS files, but then you are not using TS. If you have C# or Java experientce, then writing in TS is more like this. You can create your game class like this:

module MyGame {    export class Game extends Phaser.Game {        public static game: Phaser.Game;        // -------------------------------------------------------------------------        constructor() {            Game.game = this;            // init game            super(800, 800, Phaser.AUTO, "content", null /* , transparent, antialias, physicsConfig */);                        // states            this.state.add("Boot", Boot);            this.state.add("Preloader", Preloader);            this.state.add("Menu", Menu);            this.state.add("Play", Play);            // start            this.state.start("Boot");        }    }}   

 Or you can take a look at my tutorial for simple game in Typescript: http://sbcgamesdev.blogspot.cz/2015/05/phaser-tutorial-dronshooter-simple-game.html  You will find basic project structure there already in first part.

Share this post


Link to post
Share on other sites

Oh, I see... That makes sense. I was just renaming the files I wrote previously in JS. I'm going to follow some tutorials (like the one Tom Atom posted) and read more about Typescript to understand better how it works.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.