Jump to content

Group trouble or Pixi?


mandarin
 Share

Recommended Posts

Hi.

 

I use Phaser 1.1.3, and this code gives me this error:

Uncaught TypeError: Object TurnGroup has no method 'addChild' at line 10897

 

Here's the code:

<!DOCTYPE html><html lang="en" xmlns="http://www.w3.org/1999/xhtml"><head>    <meta charset="utf-8" />    <script src="js/phaser.min.js"></script></head><body><div id="gameContainer"></div><script type="text/javascript">SQ = {};SQ.Game = function(game) {    this.game = game;};SQ.Game.prototype = {    create: function() {        this.turn = new SQ.Turn(this);    }};SQ.Turn = function(sq_game) {    Phaser.Group.call(this, sq_game.game, 'TurnGroup', true);};SQ.Turn.prototype = Object.create(Phaser.Group.prototype);SQ.Turn.prototype.constructor = SQ.Turn;window.onload = function() {    var game = new Phaser.Game(288, 512, Phaser.CANVAS, 'gameContainer');    game.state.add('Game', SQ.Game);    game.state.start('Game');};</script></body></html>
Link to comment
Share on other sites

Ok, that works. According to the documentation Phaser.Group accepts only 4 parameters. Is the 5th documented?

 

This one used to confuse me too, and I don't know the official reason why, but the 'this' parameter in the function param list below is part of what is required when calling the generic implementation.  It never makes it to Phaser.Group constructor.

Phaser.Group.call(this, sq_game.game, null, 'TurnGroup', true);

See the answer here for a little more detail http://stackoverflow.com/questions/560829/calling-base-method-using-javascript-prototype

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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