Skip to content

Commit 08eb182

Browse files
committed
Merge branch 'develop'
2 parents 8cbe5a7 + 3a2eb77 commit 08eb182

File tree

7 files changed

+57
-14
lines changed

7 files changed

+57
-14
lines changed

src/engine/audio.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ game.createClass('Sound', {
540540

541541
this._source.buffer = this._buffer;
542542
this._source.loop = this.loop;
543-
if (this._source.playbackRate) this._source.playbackRate.setValueAtTime(this.rate, this._context.currentTime);
543+
if (this._source.playbackRate && this._context) this._source.playbackRate.setValueAtTime(this.rate, this._context.currentTime);
544544
this._source.onended = this._onComplete.bind(this);
545545
if (this._source.connect) {
546546
this._source.connect(this._gainNode);

src/engine/core.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ var game = {
9999
Engine version.
100100
@property {String} version
101101
**/
102-
version: '2.13.1',
102+
version: '2.14.0',
103103
/**
104104
@property {Boolean} _booted
105105
@private
@@ -791,6 +791,12 @@ var game = {
791791
this.device.xbox = /Xbox/i.test(navigator.userAgent);
792792
this.device.xboxOne = /Xbox One/i.test(navigator.userAgent);
793793

794+
// VR
795+
this.device.oculus = /Oculus/i.test(navigator.userAgent);
796+
this.device.oculusQuest = (this.device.oculus && /Quest/i.test(navigator.userAgent));
797+
this.device.oculusGo = (this.device.oculus && /Pacific/i.test(navigator.userAgent));
798+
this.device.gearVR = (this.device.oculus && /SAMSUNG/i.test(navigator.userAgent));
799+
794800
// Others
795801
this.device.safari = /Safari/i.test(navigator.userAgent);
796802
this.device.opera = /Opera/i.test(navigator.userAgent) || /OPR/i.test(navigator.userAgent);

src/engine/debug.js

+1-6
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@ game.createClass('Debug', {
133133
if (game.device.cocoonCanvasPlus) return;
134134

135135
game.Container.inject({
136-
_renderCachedSprite: function(context) {
137-
this.super(context);
138-
game.debug._draws++;
139-
},
140-
141136
_renderCanvas: function(context) {
142137
if (game.scene && game.scene.stage === this) return;
143138
if (game.Debug.showBounds) game.debug._drawBounds(this);
@@ -494,7 +489,7 @@ game.createClass('Debug', {
494489

495490
this._frames++;
496491

497-
var now = Date.now();
492+
var now = performance.now();
498493
if (now >= this.last + game.Debug.panelUpdate) {
499494
this.fps = Math.round(this._frames * 1000 / (now - this.last));
500495
this.last = now;

src/engine/loader.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,9 @@ game.createClass('Loader', 'Scene', {
109109
}
110110

111111
if (game.Loader.text) {
112-
this.loaderText = new game.SystemText(game.Loader.text, { size: 14 / game.scale, align: 'center', color: game.Loader.textColor });
113-
this.loaderText.position.set(game.width / 2, game.height - size / game.scale);
112+
var size = game.Loader.textSize / game.scale;
113+
this.loaderText = new game.SystemText(game.Loader.text, { size: size, align: 'center', color: game.Loader.textColor, baseline: 'bottom' });
114+
this.loaderText.position.set(game.width / 2, game.height - size - 8);
114115
this.loaderText.addTo(this.stage);
115116
}
116117

@@ -445,7 +446,7 @@ game.createClass('Loader', 'Scene', {
445446
}
446447

447448
var waitTime = game.Loader.minTime - (game.Timer.time - this._startTime);
448-
if (waitTime > 0) game.Timer.add(waitTime, this.onComplete.bind(this));
449+
if (waitTime > 0 && this.scene) game.Timer.add(waitTime, this.onComplete.bind(this));
449450
else this.onComplete();
450451
},
451452

@@ -590,7 +591,7 @@ game.addAttributes('Loader', {
590591
**/
591592
showPercent: true,
592593
/**
593-
Text to show on bottom of the loader
594+
Text to show on bottom of the loader.
594595
@attribute {String} text
595596
@default 'Made with Panda 2 - www.panda2.io'
596597
**/
@@ -600,7 +601,13 @@ game.addAttributes('Loader', {
600601
@attribute {String} textColor
601602
@default #fff
602603
**/
603-
textColor: '#fff'
604+
textColor: '#fff',
605+
/**
606+
Size of bottom loader text.
607+
@attribute {String} textSize
608+
@default 14
609+
**/
610+
textSize: 14
604611
});
605612

606613
});

src/engine/renderer/container.js

+24
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,30 @@ game.createClass('Container', {
744744
child._render(context);
745745
}
746746
},
747+
748+
/**
749+
@method _renderToContext
750+
@param {CanvasRenderingContext2D} context
751+
@param {Number} [x]
752+
@param {Number} [y]
753+
@private
754+
**/
755+
_renderToContext: function(context, x, y) {
756+
this.updateTransform();
757+
758+
var bounds = this._getBounds();
759+
760+
if (bounds.width === 0 || bounds.height === 0) return false;
761+
762+
this._worldTransform.reset();
763+
this._worldTransform.tx = x || 0;
764+
this._worldTransform.ty = y || 0;
765+
this._updateChildTransform();
766+
767+
this._renderCanvas(context);
768+
this._renderChildren(context);
769+
return true;
770+
},
747771

748772
/**
749773
@method _setStageReference

src/engine/renderer/text.js

+7
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,12 @@ game.createClass('SystemText', 'Container', {
444444
@default left
445445
**/
446446
align: 'left',
447+
/**
448+
Baseline alignment.
449+
@property {String} baseline
450+
@default alphabetic
451+
**/
452+
baseline: 'alphabetic',
447453
/**
448454
Color of the text.
449455
@property {String} color
@@ -481,6 +487,7 @@ game.createClass('SystemText', 'Container', {
481487
context.fillStyle = this.color;
482488
context.font = this.size * game.scale + 'px ' + this.font;
483489
context.textAlign = this.align;
490+
context.textBaseline = this.baseline;
484491
context.fillText(this.text, 0, 0);
485492
}
486493
});

src/engine/renderer/texture.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,11 @@ game.addAttributes('BaseTexture', {
154154
if (!baseTexture) {
155155
var source = document.createElement('img');
156156
if (this.crossOrigin) source.crossOrigin = this.crossOrigin;
157-
source.src = path + game._nocache;
157+
158+
var sourcePath = path;
159+
if (path.indexOf('data:image') === -1) sourcePath += game._nocache;
160+
source.src = sourcePath;
161+
158162
baseTexture = new game.BaseTexture(source, loadCallback);
159163
baseTexture._id = path;
160164
this.cache[path] = baseTexture;

0 commit comments

Comments
 (0)