diff --git a/src/engine/audio.js b/src/engine/audio.js index 2a46d38b..891609ca 100644 --- a/src/engine/audio.js +++ b/src/engine/audio.js @@ -540,7 +540,7 @@ game.createClass('Sound', { this._source.buffer = this._buffer; this._source.loop = this.loop; - if (this._source.playbackRate) this._source.playbackRate.setValueAtTime(this.rate, this._context.currentTime); + if (this._source.playbackRate && this._context) this._source.playbackRate.setValueAtTime(this.rate, this._context.currentTime); this._source.onended = this._onComplete.bind(this); if (this._source.connect) { this._source.connect(this._gainNode); diff --git a/src/engine/core.js b/src/engine/core.js index 0ae37440..350089d9 100644 --- a/src/engine/core.js +++ b/src/engine/core.js @@ -99,7 +99,7 @@ var game = { Engine version. @property {String} version **/ - version: '2.13.1', + version: '2.14.0', /** @property {Boolean} _booted @private @@ -791,6 +791,12 @@ var game = { this.device.xbox = /Xbox/i.test(navigator.userAgent); this.device.xboxOne = /Xbox One/i.test(navigator.userAgent); + // VR + this.device.oculus = /Oculus/i.test(navigator.userAgent); + this.device.oculusQuest = (this.device.oculus && /Quest/i.test(navigator.userAgent)); + this.device.oculusGo = (this.device.oculus && /Pacific/i.test(navigator.userAgent)); + this.device.gearVR = (this.device.oculus && /SAMSUNG/i.test(navigator.userAgent)); + // Others this.device.safari = /Safari/i.test(navigator.userAgent); this.device.opera = /Opera/i.test(navigator.userAgent) || /OPR/i.test(navigator.userAgent); diff --git a/src/engine/debug.js b/src/engine/debug.js index b090d25f..7fe1203a 100644 --- a/src/engine/debug.js +++ b/src/engine/debug.js @@ -133,11 +133,6 @@ game.createClass('Debug', { if (game.device.cocoonCanvasPlus) return; game.Container.inject({ - _renderCachedSprite: function(context) { - this.super(context); - game.debug._draws++; - }, - _renderCanvas: function(context) { if (game.scene && game.scene.stage === this) return; if (game.Debug.showBounds) game.debug._drawBounds(this); @@ -494,7 +489,7 @@ game.createClass('Debug', { this._frames++; - var now = Date.now(); + var now = performance.now(); if (now >= this.last + game.Debug.panelUpdate) { this.fps = Math.round(this._frames * 1000 / (now - this.last)); this.last = now; diff --git a/src/engine/loader.js b/src/engine/loader.js index 3c6e6415..6746c59b 100644 --- a/src/engine/loader.js +++ b/src/engine/loader.js @@ -109,8 +109,9 @@ game.createClass('Loader', 'Scene', { } if (game.Loader.text) { - this.loaderText = new game.SystemText(game.Loader.text, { size: 14 / game.scale, align: 'center', color: game.Loader.textColor }); - this.loaderText.position.set(game.width / 2, game.height - size / game.scale); + var size = game.Loader.textSize / game.scale; + this.loaderText = new game.SystemText(game.Loader.text, { size: size, align: 'center', color: game.Loader.textColor, baseline: 'bottom' }); + this.loaderText.position.set(game.width / 2, game.height - size - 8); this.loaderText.addTo(this.stage); } @@ -445,7 +446,7 @@ game.createClass('Loader', 'Scene', { } var waitTime = game.Loader.minTime - (game.Timer.time - this._startTime); - if (waitTime > 0) game.Timer.add(waitTime, this.onComplete.bind(this)); + if (waitTime > 0 && this.scene) game.Timer.add(waitTime, this.onComplete.bind(this)); else this.onComplete(); }, @@ -590,7 +591,7 @@ game.addAttributes('Loader', { **/ showPercent: true, /** - Text to show on bottom of the loader + Text to show on bottom of the loader. @attribute {String} text @default 'Made with Panda 2 - www.panda2.io' **/ @@ -600,7 +601,13 @@ game.addAttributes('Loader', { @attribute {String} textColor @default #fff **/ - textColor: '#fff' + textColor: '#fff', + /** + Size of bottom loader text. + @attribute {String} textSize + @default 14 + **/ + textSize: 14 }); }); diff --git a/src/engine/renderer/container.js b/src/engine/renderer/container.js index f5bfc74d..511e1f7f 100644 --- a/src/engine/renderer/container.js +++ b/src/engine/renderer/container.js @@ -744,6 +744,30 @@ game.createClass('Container', { child._render(context); } }, + + /** + @method _renderToContext + @param {CanvasRenderingContext2D} context + @param {Number} [x] + @param {Number} [y] + @private + **/ + _renderToContext: function(context, x, y) { + this.updateTransform(); + + var bounds = this._getBounds(); + + if (bounds.width === 0 || bounds.height === 0) return false; + + this._worldTransform.reset(); + this._worldTransform.tx = x || 0; + this._worldTransform.ty = y || 0; + this._updateChildTransform(); + + this._renderCanvas(context); + this._renderChildren(context); + return true; + }, /** @method _setStageReference diff --git a/src/engine/renderer/text.js b/src/engine/renderer/text.js index d0505747..87c8f3a7 100644 --- a/src/engine/renderer/text.js +++ b/src/engine/renderer/text.js @@ -444,6 +444,12 @@ game.createClass('SystemText', 'Container', { @default left **/ align: 'left', + /** + Baseline alignment. + @property {String} baseline + @default alphabetic + **/ + baseline: 'alphabetic', /** Color of the text. @property {String} color @@ -481,6 +487,7 @@ game.createClass('SystemText', 'Container', { context.fillStyle = this.color; context.font = this.size * game.scale + 'px ' + this.font; context.textAlign = this.align; + context.textBaseline = this.baseline; context.fillText(this.text, 0, 0); } }); diff --git a/src/engine/renderer/texture.js b/src/engine/renderer/texture.js index c2309bcd..f0c47849 100644 --- a/src/engine/renderer/texture.js +++ b/src/engine/renderer/texture.js @@ -154,7 +154,11 @@ game.addAttributes('BaseTexture', { if (!baseTexture) { var source = document.createElement('img'); if (this.crossOrigin) source.crossOrigin = this.crossOrigin; - source.src = path + game._nocache; + + var sourcePath = path; + if (path.indexOf('data:image') === -1) sourcePath += game._nocache; + source.src = sourcePath; + baseTexture = new game.BaseTexture(source, loadCallback); baseTexture._id = path; this.cache[path] = baseTexture;