Added fullscreen API|
This commit is contained in:
parent
68e205216f
commit
483ea7cc54
@ -3,6 +3,19 @@
|
|||||||
<head>
|
<head>
|
||||||
<title>Pong - MomentumEngine</title>
|
<title>Pong - MomentumEngine</title>
|
||||||
<script type="application/javascript" src="./dist/pong.js"></script>
|
<script type="application/javascript" src="./dist/pong.js"></script>
|
||||||
|
<style>
|
||||||
|
|
||||||
|
#canvas:-webkit-full-screen {
|
||||||
|
width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#canvas:fullscreen {
|
||||||
|
width: 100% !important;
|
||||||
|
height: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<canvas id="canvas"></canvas>
|
<canvas id="canvas"></canvas>
|
||||||
|
@ -318,4 +318,11 @@ window.onload = function () {
|
|||||||
pong.start();
|
pong.start();
|
||||||
|
|
||||||
|
|
||||||
|
document.addEventListener("keydown", function(e) {
|
||||||
|
if (e.keyCode == 13) {
|
||||||
|
pong.toggleFullScreen();
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "momentumengine",
|
"name": "momentumengine",
|
||||||
"version": "0.3.0",
|
"version": "0.4.0",
|
||||||
"description": "An ES6 game and animation engine.",
|
"description": "An ES6 game and animation engine.",
|
||||||
"main": "src/es6.js",
|
"main": "src/es6.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -205,6 +205,34 @@ class Game extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
toggleFullScreen () {
|
||||||
|
|
||||||
|
if (!document.mozFullScreen && !document.webkitFullScreen) {
|
||||||
|
|
||||||
|
if (this.canvas.mozRequestFullScreen) {
|
||||||
|
this.canvas.mozRequestFullScreen();
|
||||||
|
} else {
|
||||||
|
this.canvas.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (document.mozCancelFullScreen) {
|
||||||
|
document.mozCancelFullScreen();
|
||||||
|
} else {
|
||||||
|
document.webkitCancelFullScreen();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
get isFullScreen () {
|
||||||
|
return (!document.mozFullScreen && !document.webkitFullScreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user