Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ekelokorpi committed Jul 25, 2020
2 parents 8cbe5a7 + 3a2eb77 commit 08eb182
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/engine/audio.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion src/engine/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ var game = {
Engine version.
@property {String} version
**/
version: '2.13.1',
version: '2.14.0',
/**
@property {Boolean} _booted
@private
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions src/engine/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 12 additions & 5 deletions src/engine/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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();
},

Expand Down Expand Up @@ -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'
**/
Expand All @@ -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
});

});
24 changes: 24 additions & 0 deletions src/engine/renderer/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/engine/renderer/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
});
Expand Down
6 changes: 5 additions & 1 deletion src/engine/renderer/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 08eb182

Please sign in to comment.