Jump to content

Creating custom objects


Recommended Posts

I am new to Phaser and I don't have a lot of experience in Javascript. I used to work with Java and C++(languages, which have something called classes). Here I can't do the same thing.


I usually create states like this:

Game.StateName = function(game) {};


Game.StateName.prototype = {

  create: function() {},





So for example I want to create a custom object Player.

I do that in another file.

So do I need to create this same way?


Game.Player = function(game) {};


Game.Player.prototype = {

  create: function() {}



But doesnt it seem wrong? If I want to call their methods from outside?


Maybe you can show me some basic and most common way to create custom objects?

Link to comment
Share on other sites

  • 4 months later...

Hi, I started with Phaser + Javasript in January. and my background is also Java/C++. It is good to learn Javascript to know what is the same as Java/C++ and what is different. Also read about OOP in Javascirpt.


But ... out first game was Phaser + Javascript and I used Netbeans IDE. Quite comforatble, but then I tried Phaser + Typescript in MS Viesual Studio 2013 Community Edition and I would never go back. Typescript gives you back most of the constructs you know from Java/C++ with type safety while keeping flexibility of Javascript. As I said, it is good to know how Javascript works (focus on "this" keyword - most confusing for Java/C++ people at first), but Typescript boosts productivity (especially if your project is larger).

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...