erasmosoares Posted November 5, 2013 Share Posted November 5, 2013 How to create a class extending group? My intention is to create a popup class that extends group. The idea is to put all sprites, buttons to the group so that I can handle it. I've done something like that but it doesn't work. Popup = function(game, parent, name, useStage){}; Popup.prototype = Object.create( Phaser.Group.prototype);Popup.prototype.constructor = Popup; Link to comment Share on other sites More sharing options...
powerfear Posted November 5, 2013 Share Posted November 5, 2013 The way you did it should work if you add the phaser group consuctor call in your constructor: function Popup(game, parent, name, useStage) { Phaser.Group.call(this, game, parent, name, useStage);}; Popup.prototype = Object.create( Phaser.Group.prototype);Popup.prototype.constructor = Popup; or you can do it this way but it won't work if there is typeof check: function Popup(game, parent, name, useStage) { Phaser.Group.call(this, game, parent, name, useStage);}; Popup.prototype = Phaser.Utils.extend(true, Popup.prototype, Phaser.Group.prototype);Popup.prototype.constructor = Popup Link to comment Share on other sites More sharing options...
erasmosoares Posted November 6, 2013 Author Share Posted November 6, 2013 thanks for your reply, works perfectly! Link to comment Share on other sites More sharing options...
Recommended Posts