Arian Fornaris

Sublime Text plugin for auto completion Phaser API and more

Recommended Posts

Hi,

This is something that many of you are requesting for a while: an auto-completion plugin for Sublime Text.

Checkout it: https://github.com/boniatillo-com/PhaserSublimePackage

It was tested on Sublime Text 2 and 3, I just released it so if you have any issue put a comment here or open an issue in github.

This is something nice to do while we wait for the next Phaser release to deliver a Phaser Editor update ;-)

Remember Phaser Editor is a very nice complement to Sublime Text.

Have fun coding!

 

 

Autocompletion.png

Share this post


Link to post
Share on other sites

Unfortunately, I can't install this.  When I try, phaser has the following error:

plugin_host has exited unexpectedly, plugin functionality won't be available until Sublime Text has been restarted

This error persists through restarting sublime.

Sublime Text Stable Channel, Build 3103

*** EDIT *** NINJA'D, I'll try it with the new push.

Share this post


Link to post
Share on other sites
Just now, fillmoreb said:

Unfortunately, I can't install this.  When I try, phaser has the following error:

plugin_host has exited unexpectedly, plugin functionality won't be available until Sublime Text has been restarted

This error persists through restarting sublime.

Sublime Text Stable Channel, Build 3103

 

Please wait a bit, as I said, I am pushing lot of code that was ignored by git.

Share this post


Link to post
Share on other sites

This is awesome.  It's working now that I got those updated files.  A couple questions:

Is there a way to get the autocomplete to indicate a bit more visibly which things are properties and which are methods?  Right now a method looks like this: add (child,silent) and a property looks like: alive (bool).  It would be cool if properties displayed more like alive:bool.  It would be easier to tell at a glance what is what.

Also, while playing around, I noticed that Phaser.Group didn't have the scale property available in the autocomplete.  How would I go in to add missing properties?

Thanks again for the great plugin.

autocomplete.png

Share this post


Link to post
Share on other sites

Haha, this is great. Maybe it's finally time for me to move away from Notepad++ NOW! This is a perfectly valid reason eh?! :D

 

Also, how did you get a light skin on sublime? I always hated the dark skin one, which was why I never really made the switch. I like the clear / white notepad ++ feel.

Share this post


Link to post
Share on other sites

Hello, this is a great plugin , I would like to use it. But I'm having some problem. My basic project template is that I make 1 my game object like CTB. Then I make other objects like "Boot", "Preload", "Menu", "Game", "Ending" etc from the CTB object. And different preload, create, update inside those objects.I also put "Boot", "Preload", "Menu", "Game", "Ending" etc in different files and put them together in the index.html file. Here is an example of my object creation.

CTB.Loader = function(game){};
CTB.Loader.prototype ={
    preload: function(){
        this.add.sprite(0,0, "banana");
    },
    create: function(){
        this.state.start("Menu");
    }

//use update: function(){} if needed
};

the problem is that when I try to use the code hinting inside any of the preload, create, update function I don't get any.hinting. Is there anyway for me to solve this?

The hinting works when I try to use it like this

CTB = {};
CTB.test = function(){}
CTB.test.prototype = Object.create(Phaser.State.prototype);
CTB.test.prototype.constructor = CTB.test;
CTB.test.prototype.create = function(){
}

But not like this

CTB = {};
CTB.test = function(){}
CTB.test.prototype = Object.create(Phaser.State.prototype);
CTB.test.prototype.constructor = CTB.test;
CTB.test.prototype = {
create: function(){

}
};

I'm new to phaser and javascript as a whole. I have no idea why this is happening. I have many projects already created, I would like to use the hinting in those. how can I add the hinting to my projects.

thanks in advance if you reach this far =).

Share this post


Link to post
Share on other sites
8 hours ago, WombatTurkey said:

Haha, this is great. Maybe it's finally time for me to move away from Notepad++ NOW! This is a perfectly valid reason eh?! :D

 

Also, how did you get a light skin on sublime? I always hated the dark skin one, which was why I never really made the switch. I like the clear / white notepad ++ feel.

The theme of the screenshots is iPlastic, go to Preferences > Color Scheme > iPlastic

I love notepad++ too, it is so fast! I am sure that you can find a theme like notepad++ in sublime, even it should no be to hard to create it yourself :-)

Share this post


Link to post
Share on other sites

@minhaz1217 The problem is that in the first case it is not working to you, the inference engine has no way to know that you are creating a "sub-class".

In JavaScript the inheritance is expressed like you do in the second snippet.

JavaScript is very flexible, but if you like content assist you have to follow certain rules, for example, annotating method parameters with jsdoc tags etc...

Share this post


Link to post
Share on other sites

When I add phaser.js to my project the auto-completion doesn't work. As soon as I start typing the error pops up saying

"Failed to start server C:/wamp64/www/MyTestProject/phaser.js:3081... "

If I get rid of the phaser.js file it is working, but then I cannot start my project, it shows a blank page. Any idea how to fix that ?

Share this post


Link to post
Share on other sites

Hi @skinwalker

The package uses ternjs so your `.tern-project` file is your best friend.

You can read how to configure it here:

http://ternjs.net/doc/manual.html#configuration

Try by changing the `.tern-project` file like this: 

 

{
  "libs": ["browser"],
  "plugins" : {
 	"phaser" : {},
 	"doc_comment": {}
  },
  "dontLoad" : ["lib/phaser.js"]
}

 

 

 

Share this post


Link to post
Share on other sites

This doesn't resolve the issue. If I move the phaser.js file in another directory or just delete it, the plugin works fine, but then I cannot start my project

 

Here is a screenshot of the error, I am getting as soon as I start typing, when I have phaser.js in my directory : 8n3N6gF.png

Share this post


Link to post
Share on other sites
6 minutes ago, Arian Fornaris said:

Well... I don't know what could be the problem. The only thing I can do for you is to test your project here in my machine.

There is nothing specific in the project, just a javascript file + phaser + .tern file. Can you show me how your project's structure looks like ? Also, what I did is just followed these 7 steps from the github link, I haven't installed anything else.

Share this post


Link to post
Share on other sites
39 minutes ago, Arian Fornaris said:

Yes, I was able to reproduce the error. The "dontLoad" is not working, please can you open an issue in github?

 

https://github.com/boniatillo-com/PhaserSublimePackage/issues

 

As work around you can rename `phaser.js` to `phaser.min.js` it worked for me.

Thanks man, it also works for me !! I opened an issue in github.

So what is the difference between phaser.js and phaser.min.js ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.