Jump to content

Problem with Phaser.Game inheritance


mitrey
 Share

Recommended Posts

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?

 

example.jpg

Link to comment
Share on other sites

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

example2.jpg

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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