mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
Merge branch 'v1.9'
# Conflicts: # CCBoot.js # cocos2d/audio/CCAudio.js # cocos2d/core/sprites/CCScale9Sprite.js
This commit is contained in:
+13
-16
@@ -107,8 +107,13 @@ Audio.State = {
|
||||
|
||||
proto._onLoaded = function () {
|
||||
if (this._src.loadMode === LoadMode.DOM_AUDIO) {
|
||||
this._element = document.createElement('audio');
|
||||
this._element.src = this._src._nativeAsset.src;
|
||||
if (CC_QQPLAY || CC_WECHATGAME) {
|
||||
this._element = elem;
|
||||
}
|
||||
else {
|
||||
this._element = document.createElement('audio');
|
||||
this._element.src = this._src._nativeAsset.src;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this._element = new WebAudioElement(this._src._nativeAsset, this);
|
||||
@@ -138,7 +143,7 @@ Audio.State = {
|
||||
this._bindEnded();
|
||||
this._element.play();
|
||||
|
||||
if (sys.platform !== sys.WECHAT_GAME &&
|
||||
if (!(CC_QQPLAY || CC_WECHATGAME) &&
|
||||
this._src && this._src.loadMode === LoadMode.DOM_AUDIO &&
|
||||
this._element.paused) {
|
||||
touchPlayList.push({ instance: this, offset: 0, audio: this._element });
|
||||
@@ -178,17 +183,9 @@ Audio.State = {
|
||||
|
||||
proto.stop = function () {
|
||||
if (!this._element) return;
|
||||
if (CC_WECHATGAME) {
|
||||
setTimeout(function () {
|
||||
try {
|
||||
this._element.currentTime = 0;
|
||||
} catch (error) {}
|
||||
}.bind(this), 0);
|
||||
} else {
|
||||
try {
|
||||
this._element.currentTime = 0;
|
||||
} catch (error) {}
|
||||
}
|
||||
try {
|
||||
this._element.currentTime = 0;
|
||||
} catch (error) {}
|
||||
this._element.pause();
|
||||
// remove touchPlayList
|
||||
for (var i=0; i<touchPlayList.length; i++) {
|
||||
@@ -232,7 +229,7 @@ Audio.State = {
|
||||
}
|
||||
|
||||
this._unbindEnded();
|
||||
if (sys.platform !== sys.WECHAT_GAME) {
|
||||
if (!(CC_QQPLAY || CC_WECHATGAME)) {
|
||||
this._bindEnded(function () {
|
||||
this._bindEnded();
|
||||
}.bind(this));
|
||||
@@ -384,7 +381,7 @@ var WebAudioElement = function (buffer, audio) {
|
||||
var self = this;
|
||||
clearTimeout(this._currextTimer);
|
||||
this._currextTimer = setTimeout(function () {
|
||||
if (sys.platform !== sys.WECHAT_GAME && self._context.currentTime === 0) {
|
||||
if (!(CC_QQPLAY || CC_WECHATGAME) && self._context.currentTime === 0) {
|
||||
touchPlayList.push({
|
||||
instance: self._audio,
|
||||
offset: offset,
|
||||
|
||||
@@ -158,7 +158,7 @@ _ccsg.Label = _ccsg.Node.extend({
|
||||
|
||||
_ccsg.Node.prototype.ctor.call(this);
|
||||
this.setAnchorPoint(0.5, 0.5);
|
||||
_ccsg.Node.prototype.setContentSize.call(this, 128, 128);
|
||||
_ccsg.Node.prototype.setContentSize.call(this, 10, 10);
|
||||
this._blendFunc = cc.BlendFunc._alphaNonPremultiplied();
|
||||
|
||||
this._imageOffset = cc.p(0, 0);
|
||||
@@ -1271,14 +1271,13 @@ _ccsg.Label.pool = new JS.Pool(function (label) {
|
||||
label._fontHandle = "";
|
||||
label._labelType = 0;
|
||||
label._resetBMFont();
|
||||
label._renderCmd._labelCanvas.width = 1;
|
||||
label._renderCmd._labelCanvas.height = 1;
|
||||
label._renderCmd._texture.releaseTexture();
|
||||
if (CC_DEV) {
|
||||
cc.assert(!label._parent, 'Recycling label\'s parent should be null!');
|
||||
}
|
||||
label._updateLabel();
|
||||
return true;
|
||||
}, 20);
|
||||
}, 120);
|
||||
|
||||
_ccsg.Label.pool.get = function (string, fontAsset) {
|
||||
var label = this._get();
|
||||
@@ -1294,7 +1293,7 @@ _ccsg.Label.pool.get = function (string, fontAsset) {
|
||||
label._position.x = 0;
|
||||
label._position.y = 0;
|
||||
label.setAnchorPoint(0.5, 0.5);
|
||||
_ccsg.Node.prototype.setContentSize.call(label, 128, 128);
|
||||
_ccsg.Node.prototype.setContentSize.call(label, 10, 10);
|
||||
|
||||
if (isAsset) {
|
||||
label.setFontAsset(fontAsset);
|
||||
|
||||
@@ -400,7 +400,7 @@
|
||||
};
|
||||
|
||||
proto._updateTexture = function() {
|
||||
this._labelContext.clearRect(0, 0, this._labelCanvas.width, this._labelCanvas.height);
|
||||
this._labelContext.clearRect(0, 0, this._canvasSize.width, this._canvasSize.height);
|
||||
|
||||
this._labelContext.font = this._fontDesc;
|
||||
|
||||
|
||||
@@ -31,12 +31,14 @@
|
||||
http://www.angelcode.com/products/bmfont/ (Free, Windows only)
|
||||
****************************************************************************/
|
||||
|
||||
var _sharedLabelCanvas;
|
||||
_ccsg.Label.WebGLRenderCmd = function(renderableObject){
|
||||
this._rootCtor(renderableObject);
|
||||
this._needDraw = true;
|
||||
|
||||
this._texture = new cc.Texture2D();
|
||||
this._labelCanvas = document.createElement("canvas");
|
||||
_sharedLabelCanvas = _sharedLabelCanvas || document.createElement('canvas');
|
||||
this._labelCanvas = _sharedLabelCanvas;
|
||||
this._texture.initWithElement(this._labelCanvas);
|
||||
this._labelContext = this._labelCanvas.getContext("2d");
|
||||
|
||||
@@ -66,8 +68,8 @@ proto.updateTransform = function (parentCmd) {
|
||||
this.originUpdateTransform(parentCmd);
|
||||
|
||||
var node = this._node,
|
||||
lx = 0, rx = this._labelCanvas.width,
|
||||
by = 0, ty = this._labelCanvas.height,
|
||||
lx = 0, rx = this._node.width,
|
||||
by = 0, ty = this._node.height,
|
||||
wt = this._worldTransform;
|
||||
|
||||
var vert = this._vertices;
|
||||
|
||||
@@ -629,6 +629,15 @@ else if (CC_WECHATGAME) {
|
||||
else if (env.platform === "ios") {
|
||||
sys.os = sys.OS_IOS;
|
||||
}
|
||||
else if (env.platform === 'devtools') {
|
||||
var system = env.system.toLowerCase();
|
||||
if (system.indexOf('android') > -1) {
|
||||
sys.os = sys.OS_ANDROID;
|
||||
}
|
||||
else if (system.indexOf('ios') > -1) {
|
||||
sys.os = sys.OS_IOS;
|
||||
}
|
||||
}
|
||||
|
||||
var version = /[\d\.]+/.exec(env.system);
|
||||
sys.osVersion = version[0];
|
||||
@@ -681,7 +690,7 @@ else if (CC_QQPLAY) {
|
||||
|
||||
var version = /[\d\.]+/.exec(env.version);
|
||||
sys.osVersion = version[0];
|
||||
sys.osMainVersion = parseInt(osVersion.split('.')[0]);
|
||||
sys.osMainVersion = parseInt(sys.osVersion.split('.')[0]);
|
||||
sys.browserType = sys.BROWSER_TYPE_QQ_PLAY;
|
||||
sys.browserVersion = 0;
|
||||
|
||||
|
||||
@@ -1171,10 +1171,7 @@ cc.Scale9Sprite = _ccsg.Node.extend({
|
||||
this._renderCmd._needDraw = false;
|
||||
var self = this;
|
||||
function onResourceDataLoaded () {
|
||||
if (!self.isValid) {
|
||||
return;
|
||||
}
|
||||
if (self._contentSize.width === 0 && self._contentSize.height === 0) {
|
||||
if (self._spriteFrame && self._contentSize.width === 0 && self._contentSize.height === 0) {
|
||||
self.setContentSize(self._spriteFrame._rect);
|
||||
}
|
||||
self._renderCmd._needDraw = true;
|
||||
|
||||
Reference in New Issue
Block a user