guddy Posted August 21, 2014 Share Posted August 21, 2014 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 More sharing options...
eguneys Posted August 21, 2014 Share Posted August 21, 2014 what is the error? Link to comment Share on other sites More sharing options...
Sebi Posted August 21, 2014 Share Posted August 21, 2014 var obj = function(){ Phaser.State.call(this); this.x = 20; this.y = 20; } obj.prototype = Object.create(Phaser.State.prototype); obj.prototype.constructor = obj; codevinsky 1 Link to comment Share on other sites More sharing options...
guddy Posted August 22, 2014 Author Share Posted August 22, 2014 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 More sharing options...
eguneys Posted August 22, 2014 Share Posted August 22, 2014 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 More sharing options...
guddy Posted August 22, 2014 Author Share Posted August 22, 2014 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 More sharing options...
Recommended Posts