Statically define canvas, maybe this will fix ios.

Make loader code actually work again (I think)
This commit is contained in:
Rob Pearce 2016-08-28 08:27:20 +10:00
parent 614c2e3da8
commit aa59291af4
1 changed files with 16 additions and 5 deletions

View File

@ -24,8 +24,15 @@
<link rel="icon" sizes="192x192" href="images/icon-192.png">
<style>
body {
margin: 0;
padding: 0;
background: #000000;
}
canvas {
border:1px solid #d3d3d3;
display: block;
margin: 0 auto;
background-color: #000000;
}
@font-face {
@ -35,9 +42,11 @@ canvas {
</style>
</head>
<body style="margin: 0; padding:0;" bgcolor="#000000" onload="startGame()">
<canvas></canvas>
<script>
var FONT = "BlueStone";
// canvas style did have : border:1px solid #d3d3d3;
// game vars
var things = [];
@ -259,7 +268,7 @@ var maximages = 0;
function loadimage(name, filename) {
image[name] = new Image();
image[name].onload = game.incloadprogress();
image[name].onload = game.incloadprogress;
image[name].src = filename;
}
@ -988,12 +997,13 @@ var game = {
ctx.fillStyle = bgcol;
this.context.fillRect(0, 0, this.canvas.width, pct * this.canvas.height);
this.dirty = true;
console.log("loader");
console.log("drawing loader");
},
init : function() {
this.canvas = document.createElement("canvas");
//this.canvas = document.createElement("canvas");
this.canvas = document.getElementsByTagName('canvas')[0];
this.stargoalbanner = document.createElement("canvas");
this.hratio = SCREENH / SCREENW;
@ -1018,7 +1028,8 @@ var game = {
this.android = this.ua.indexOf('android') > -1 ? true : false;
this.ios = ( this.ua.indexOf('iphone') > -1 || this.ua.indexOf('ipad') > -1 ) ? true : false;
document.body.insertBefore(this.canvas, document.body.childNodes[0]);
// don't need this now that we statically define the canvas.
//document.body.insertBefore(this.canvas, document.body.childNodes[0]);
// try to go full screen?
/*