Skip to content
Snippets Groups Projects
Commit abe43b43 authored by Sebastian Hölscher's avatar Sebastian Hölscher
Browse files

Added login state and state manager

parent 42f5cc57
No related branches found
No related tags found
No related merge requests found
Phaser.Device.whenReady(function () {
game.plugins.add(PhaserInput.Plugin);
});
\ No newline at end of file
var Login = {
nameBox: null
};
Login.init = function() {
if(false === game.device.desktop){
this.optimizeMobileView();
}
game.scale.pageAlignHorizontally = true;
}
Login.optimizeMobileView = function() {
console.log('W : '+window.screen.width+', H : '+window.screen.height);
if(Math.min(window.screen.width, window.screen.height) < game.width) { // If at least one of the two screen dimensions is smaller for the game, enable asking for device reorientation
game.scale.scaleMode = Phaser.ScaleManager.RESIZE;
game.scale.forceOrientation(true,false);
}
}
Login.preload = function() {
};
Login.create = function() {
this.stage.backgroundColor = 0x00F0F0;
this.nameBox = game.add.inputField(10, 90, {
font: '18px Arial',
fill: '#212121',
width: this.game.width - 36,
padding: 8,
borderWidth: 1,
borderColor: '#000',
borderRadius: 6,
placeHolder: 'Please enter your name'
});
this.loginButton = game.add.button(10, 130, '', Login.login, this);
};
Login.login = function() {
};
\ No newline at end of file
var game = new Phaser.Game(
800,
600,
Phaser.CANVAS,
document.getElementById('game-div'),
null,
false,
true);
game.state.add('Login', Login);
//game.state.add('Game', Game);
game.state.start('Login');
......@@ -5,6 +5,9 @@
<body>
<div id="game-div"></div>
</body>
<script src="client/phaser-input.js"></script>
<script src="client/phaser.js"></script>
<script type="text/javascript" src="client/phaser.js"></script>
<script type="text/javascript" src="client/phaser-input.js"></script>
<script type="text/javascript" src="client/login.js"></script>
<script type="text/javascript" src="client/main.js"></script>
<script type="text/javascript" src="client/init.js"></script>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment