Jump to content

guddy
 Share

Recommended Posts

Hi,

I have create class which i want to have state prototype .So i have try to use extending method .But i am facing some error

 

/**code**/ 

var obj = function(){

    this.x = 20;

    this.y = 20; 

}

obj.prototype = Object.create(Phaser.State.prototype);

obj.prototype.constructor = obj;

//basically  i want to preload function of Phaser.State

//But it is not working 

 

plz help me out

Link to comment
Share on other sites

Hi,

Thanks for reply but it is not working

 

Well in console there is no error .But my problem is the class which i have  created is not getting extended the prototype of "Phaser.state"  .Actually i wants preload function of state class to access .

var obj = function(){

    this.x = 20;

    this.y = 20; 

}

obj.prototype = Object.create(Phaser.State.prototype);

obj.prototype.constructor = obj;

obj.prototype.preload = function(){

         console.log("in preload");    

}

 

thanks

Link to comment
Share on other sites

Maybe you don't need to extend from Phaser.State. Just use it like this:

var obj = function(){    this.x = 20;    this.y = 20; }obj.prototype.preload = function(){         console.log("in preload");    }

Also make sure to add this state to the game and start it.

game.state.add('obj', obj);game.state.start('obj');
Link to comment
Share on other sites

Actually i am not loading whole image at one time .So i need to pass parameter to preload function for which screen number is to load and where to send callback function.

Basic i am working on progressive loading mean i am loading the image while playing game.

 

So need to class which having state prototype. If u know the solve let know

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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