Jump to content

code not understood


arun
 Share

Recommended Posts

it's bizarre i've seen something like this one day that takes the game instance in parameter but the right syntax is

game = new Phaser.Game(800, 600);

and after in the function parameter you can add more stuff, then you go on the definition of the functions like preload, create and update

Link to comment
Share on other sites

var gameTitle = function(game){}

gameTitle.prototype = {
  create: function(){}
}

It's a JS pattern to add class-like behaviour into a prototypal language, if you know what classes are (in Java, C++ etc for example) then its pretty akin to that. The top function call is a constructor function, the prototype bit adds methods (behaviours) to your class. You should just call this an object as JS doesn't have traditional classes (despite the new class syntax).

The way you're doing it though stamps over any existing methods on the prototype, this is generally bad, sometimes very bad.

Extending the checkout with additional functionality is fine but be careful stamping over it, particularly if you're setting up some sort of inheritance chain.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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