espace 25 Posted July 6, 2018 Report Share Posted July 6, 2018 hi, i would work with separate files. the problem, i create my sprite config before and i would access the game.height to put them correctly in the screen. minimum example code //parameter.js var circle; var circle2; //proto.js before main.js var create_circle=()=>{ circle = game.add.graphics(0, 0); circle.beginFill(0xFF0000, 1); circle.drawCircle(300, game.height*.3, 100); } //main.js var config = { width: 800, height: 800, renderer: Phaser.CANVAS, antialias: true, multiTexture: true, state: { preload: create, update: update }, } let game = new Phaser.Game(config); var circle; function create () { this.game.scale.pageAlignHorizontally = true; this.game.scale.pageAlignVertically = true; this.game.scale.refresh(); circle2 = game.add.graphics(0, 0); circle2.beginFill(0xFF0000, 1); //HERE IT'S EASY circle2.drawCircle(300, game.height*.3, 100); // HERE IT DON'T WORK AND IT'S NORMAL BECAUSE GAME DON'T EXIST //BUT IS THERE A WAY TO ACCESS GAME.HEIGHT ??? //window.innerHeight is not the same than game.height ! create_circle() } function update () { } Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.