Jump to content

unable to instantiate Phaser object in intel xdk


shohan4556
 Share

Recommended Posts

Hello guys I am new in xdk I have a little problem I know there might be a little solution, so my problem is that, I have a Menu.js file and menuButton.js file I am trying to create menuButton object but its fire up an error like Uncaught TypeError: Cannot read property 'sprite' of undefined.

 

my Menu.js file 

BasicGame.menuState = function(game){    };BasicGame.menuState.prototype = {        create: function(){          BasicGame.global.menuBgSound = this.game.add.audio('menuBg',1,true);        BasicGame.global.menuBgSound.play();                  this.buttons = new menuButton(game); // error        this.buttons.create(); // error     },        update: function(){            }    }

my menuButton.js file

var menuButton = function(game){    //this.game = game; // tried this not working // error - Uncaught TypeError: Cannot read property 'add' of undefined     };menuButton.prototype = {        create: function(){        this.playButton = this.game.add.sprite(100,100,'playButton');    },        update: function(){            }    }

the did the same formation in my Bracket editor and that was fine but in xdk it occurs error. I have tried several ways but the result is nothing.

Thanks 

Link to comment
Share on other sites

Hi
I'v just fixed your trouble.
So:
1) Menu.js : 17 replace with 

this.buttons = new BasicGame.menuButton(this.game);

2) Button.js 

BasicGame.menuButton = function(game){    this.game = game;};BasicGame.menuButton.prototype = {        create: function(){        this.playButton = this.game.add.sprite(100,100,'platform');    },        update: function(){            }    }
Link to comment
Share on other sites

 

Hi

I'v just fixed your trouble.

So:

1) Menu.js : 17 replace with 

this.buttons = new BasicGame.menuButton(this.game);

2) Button.js 

BasicGame.menuButton = function(game){    this.game = game;};BasicGame.menuButton.prototype = {        create: function(){        this.playButton = this.game.add.sprite(100,100,'platform');    },        update: function(){            }    }

 

 

Thanks man :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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