mitrey Posted October 5, 2017 Share Posted October 5, 2017 I got stuck. I need to inherit Phaser.Game to extend the game class functionality. class Game extends Phaser.Game { constructor() { super(arguments); } getSomeLogic() { // new game method } } Then within Boot state i scale the game. class Boot { preload() { this.load.image('background', 'assets/background.jpg'); } create() { this.game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; this.add.sprite(0, 0, 'background'); } } For this point all works as expected. But, when i add new sprite it scales wrong. Sprite is cropped by scaled game bounds. ( look at example screen ) Guys, what i am doing wrong? Link to comment Share on other sites More sharing options...
samme Posted October 5, 2017 Share Posted October 5, 2017 I think it depends on what you expect to happen, but do either of: Increase game dimensions (width, height) to at least the background image dimensions Reduce image scale so it fits in the game dimensions Link to comment Share on other sites More sharing options...
mitrey Posted October 5, 2017 Author Share Posted October 5, 2017 1 hour ago, samme said: I think it depends on what you expect to happen, but do either of: Increase game dimensions (width, height) to at least the background image dimensions Reduce image scale so it fits in the game dimensions when i create game with Phaser.Game (original class) all sprites scale as i want. Look attached file with example of my expectations Link to comment Share on other sites More sharing options...
samme Posted October 5, 2017 Share Posted October 5, 2017 In that case, the super call may be wrong. Try constructor(...args) { super(...args); } Link to comment Share on other sites More sharing options...
mitrey Posted October 6, 2017 Author Share Posted October 6, 2017 Thank you, but variable 'arguments' gets all parameters passed to function. And debugger confirms me that Link to comment Share on other sites More sharing options...
Recommended Posts