phaser/examples/display/fullscreen.js

45 lines
922 B
JavaScript
Raw Normal View History

2013-10-22 02:58:20 +00:00
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('dragon', 'assets/pics/cougar_dragonsun.png');
2013-10-22 02:58:20 +00:00
}
function create() {
var sprite = game.add.sprite(game.world.centerX, game.world.centerY, 'dragon');
sprite.anchor.set(0.5);
2013-10-22 02:58:20 +00:00
game.stage.backgroundColor = '#000';
2013-10-22 02:58:20 +00:00
// Stretch to fill
game.scale.fullScreenScaleMode = Phaser.ScaleManager.EXACT_FIT;
// Keep original size
// game.scale.fullScreenScaleMode = Phaser.ScaleManager.NO_SCALE;
// Maintain aspect ratio
// game.scale.fullScreenScaleMode = Phaser.ScaleManager.SHOW_ALL;
2013-10-22 02:58:20 +00:00
game.input.onDown.add(gofull, this);
}
function gofull() {
2014-02-21 15:53:07 +00:00
game.scale.startFullScreen();
2013-10-22 02:58:20 +00:00
}
function update() {
}
function render () {
game.debug.renderText('Click / Tap to go fullscreen', 270, 16);
2013-10-22 02:58:20 +00:00
}