Octavia Posted April 2, 2015 Share Posted April 2, 2015 Hi everyone, i ran into a pretty weird problem while trying to get started with phaser. When i try to change the scaleMode to EXACT_FIT with the following line:var game = new Phaser.Game("100%", "100%", Phaser.AUTO, '', { preload: onPreload, create: onCreate, update: onUpdate, resize: onResize });game.scale.scaleMode = Phaser.ScaleManager.EXACT_FIT;But it allways tells me that it can't get scaleMode from Null. When i do a console.log of the game variable scale exists.When i console.log game.scale it is Null. I have no idea how that happens or what i can do about this. I hope someone can help me out on this. Any help is appreciated : ) Best regards, Octavia Link to comment Share on other sites More sharing options...
rich Posted April 2, 2015 Share Posted April 2, 2015 It's most likely because at the point you are setting "game.scale" Phaser hasn't yet fully loaded or started, so the Scale Manager isn't yet ready. Try putting the call inside an init function:var game = new Phaser.Game("100%", "100%", Phaser.AUTO, '', { init: init, preload: onPreload, create: onCreate, update: onUpdate, resize: onResize }); function init() { game.scale.scaleMode = Phaser.ScaleManager.EXACT_FIT;}You'll also need the rest of the functions you've defined (preload, etc). Link to comment Share on other sites More sharing options...
Octavia Posted April 2, 2015 Author Share Posted April 2, 2015 Thank you rich, that solved it perfectly. : ) Don't worry, i only left the other function definitions out to make it easier to read, since i didn't think they would be of any help in this snippet. Cheers, Octavia Link to comment Share on other sites More sharing options...
Recommended Posts