Titus Posted August 14, 2017 Share Posted August 14, 2017 Hi, Just wondering if it is possible to define the scaling for a game only once in a single state (rather than in every state) and it is applied to all states thereafter? In the game I'm currently making I have a boot state and I want to define the scaling only once in the init function but it doesn't seem to apply to any following states and I have to define these settings on all pages: This is the code I'm using for scaling if it helps at all: init: function() { this.scale.pageAlignHorizontally = true; this.scale.scaleMode = Phaser.ScaleManager.USER_SCALE; this.scale.setUserScale(0.445, 0.445, 0, 0); }, I'm sure I must be missing something obvious. Any help would be appreciated. Link to comment Share on other sites More sharing options...
snowbillr Posted August 14, 2017 Share Posted August 14, 2017 I'm in the same boat. I was going to make a `MobileState` that implements this functionality and extend all my other states from there, but would love to know if there is a singular place in that I can define it. I guess it makes sense that it needs to happen in individual states since any resizing logic would be specific to each state, but for the more generic parts of setting up scale modes, I'd like to put it somewhere a little more singular. Link to comment Share on other sites More sharing options...
samme Posted August 14, 2017 Share Posted August 14, 2017 scaleMode can be set in the Phaser.Game config object. Any other scale settings can be done (at most once) in a boot state. They're not state-specific and they shouldn't be affected by changing states. Titus 1 Link to comment Share on other sites More sharing options...
Titus Posted August 15, 2017 Author Share Posted August 15, 2017 @samme Thanks for the reply. You are correct. I'm not sure what was going on yesterday but today I've tested it again and the scaling defined at boot is being applied to the rest of the game. I think I might have had some images cached. Link to comment Share on other sites More sharing options...
Recommended Posts