shohan4556 Posted November 18, 2015 Share Posted November 18, 2015 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 filevar 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 More sharing options...
quiphop Posted November 18, 2015 Share Posted November 18, 2015 HiI'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(){ } } shohan4556 1 Link to comment Share on other sites More sharing options...
shohan4556 Posted November 18, 2015 Author Share Posted November 18, 2015 HiI'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 More sharing options...
Skeptron Posted November 18, 2015 Share Posted November 18, 2015 Common man, mark his post as answered, not yours... So BM... Link to comment Share on other sites More sharing options...
Recommended Posts