Basically, I stumbled upon this thread: http://www.html5gamedevs.com/topic/1609-centering-canvas/
But it doesn't work. Basically after poking around in other threads and spending around an hour to do so, I realized that the code is wrong. You're supposed to put this code inside the create() function:
this.game.scale.pageAlignHorizontally = true;
this.game.scale.pageAlignVertically = true;
this.game.scale.refresh();
and voila, it's in the center.
(But it's not in the center when I put it in the web. Dammit, some more problems to solve.)
The next one is I want the camera to follow the player. Now I'm not sure why I seemed to be having a hard time yesterday, but actually it's just putting this code inside the function create():
player.anchor.setTo(0.5, 0.5);
game.camera.follow(player, Phaser.Camera.FOLLOW_PLATFORMER);
And you don't actually need the first line. See how easy it is to do stuff in Phaser? :D
No comments:
Post a Comment