Skip to content

Commit

Permalink
V2.1 release merge v2.0 release (#3995)
Browse files Browse the repository at this point in the history
* Add RenderMode TS support (#3879)

Add spine assembler var define

* fix unit test for sprite (#3870)

* Fix 1.x to 2.x particle custom data is invalid bug (#3885)

* Improve particle definition data code (#3892)

* fix event failed to reorder after modifying zIndex for 2d-tasks/issues/1130 (#3895)

* Move BlendFunctionFactors to Sprite and ParticleSystem only (#3900)

* change API:loadSubpackage to load index.js (#3899)

* mark component.enabled as animatable (#3898)

* ban JIT support on baidugame (#3903)

* Fix dragonbones multiple texture bug (#3897)

* Fix dragonbones change cloth bug

* Adapt to old api-> on off once

* DragonBonesAsset do not store dragonBones data

* fix some error

* fix web spine debug draw color error

* Set limit time to 30s

* fix label rendering in open data context (#3911)

* fix: shaders have same uniform name, different type will effect wrong (#3876)

* fix: shaders have same uniform name, different type will effect wrong

* fix shaders have same uniform name, different type will effect wrong

* fix shaders have same uniform name, different type will effect wrong, refine

* add deprecated property in EditBox in v2.0 (#3912)

* Fix dragonbones exception (#3914)

* revert particles system attribute definition (#3919)

* fix emit target scale changed events twice (#3922)

* add the tween test case (#3908)

* add the tween test case

* modify the format of the test-tween.js

1. keep all chain method start at the char 'n' below

* fixed the tween bugs

* Fix spine premultipliedAlpha serialize bug (#3924)

* cancel disable dynamic atlas on chrome. (#3929)

* Add cache mode of label. (#3916)

* Add cache mode of label.

* fix revised comments of pr.

* Simplified variable name.

* share canvas pool.

* cancel use node color.

* modify comment and reserve _batchAsBitMap.

* optimize the assignment of color and delete blendFactor.

* delete reserveImage.

* modify to center alignment.

* modify letter-font do not use node color.

* add outline support of letter-font

* add letter atlas reset on editor when scene loaded.

* change LETTER to CHAR

* modify comment

* Wechat -> WeChat

* Add spine render mode chinese tip (#3933)

* fix label rendering error on native (#3936)

* fix label rendering error on native

* fix rendering error on native

* revert first commit

* clear letter atlas when scene launch. (#3938)

*  reset the CHAR mode to NONE on subdomin. (#3940)

* reset the CHAR mode to NONE on subdomin.

* reset CHAR mode on subdomin

* set rigidbody awake visible is false (#3941)

* fix canvasPool error on subdomin (#3942)

* update rigidbody awake tips and add awakeOnLoad (#3944)

* fix label error when font change on editor. (#3946)

* Rename skeleton RenderMode to AnimationCacheMode (#3947)

* Rename skeleton RenderMode to AnimationCacheMode

* Rename skeleton RenderMode to AnimationCacheMode

* fix label blur when using dark font color (#3949)

* optimize editBox style (#3952)

* To adapt the adjust of the webview impl in the jsb (#3697) (#3951)

* fix the problem of label that first modified is invalid. (#3959)

* Fix create ArmatureDisplay by code but no set asset, then invoke some api about event, will throw error (#3966)

* fix get auido state bug (#3974)

* small fixed

* small fixed
  • Loading branch information
2youyou2 authored and pandamicro committed Mar 11, 2019
1 parent d32ffa8 commit 9c498d7
Show file tree
Hide file tree
Showing 46 changed files with 2,477 additions and 585 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.txt
Expand Up @@ -323,7 +323,7 @@ Cocos2d-JS v3.2 @ Dec.29, 2014
* Replaced `transform` function with `setTransform` function under canvas render mode for better performance.
* Added a timer in `cc.audioEngine` to check audio element loading event, prevent the loading process being stucked when load audio file failed.
* Added some new browser types to `cc.sys`.
* Added some audio resource loading codes to ensure compatibility with Wechat browser.
* Added some audio resource loading codes to ensure compatibility with WeChat browser.
* Added check for WebAudio support to ensure compatibility.

* Bug fixes:
Expand Down
4 changes: 2 additions & 2 deletions cocos2d/actions/tween.js
@@ -1,6 +1,6 @@

let TweenAction = cc.Class({
name: 'TweenAction',
name: 'cc.TweenAction',
extends: cc.ActionInterval,

ctor (duration, props, opts) {
Expand Down Expand Up @@ -224,7 +224,7 @@ Tween.prototype._get = function () {
actions = actions[0];
}
else {
actions = Tween.sequence(actions);
actions = cc.sequence(actions);
}

return actions;
Expand Down
9 changes: 6 additions & 3 deletions cocos2d/audio/CCAudio.js
Expand Up @@ -267,13 +267,16 @@ Audio.State = {
};

proto.getState = function () {
if (!CC_WECHATGAME && !CC_QQPLAY) {
let elem = this._element;
if (!CC_WECHATGAME && !CC_QQPLAY && elem) {
// HACK: in some browser, audio may not fire 'ended' event
// so we need to force updating the Audio state
let elem = this._element;
if (elem && Audio.State.PLAYING === this._state && elem.paused) {
if (Audio.State.PLAYING === this._state && elem.paused) {
this._state = Audio.State.STOPPED;
}
else if (Audio.State.STOPPED === this._state && !elem.paused) {
this._state = Audio.State.PLAYING;
}
}
return this._state;
};
Expand Down
4 changes: 0 additions & 4 deletions cocos2d/core/CCGame.js
Expand Up @@ -798,10 +798,6 @@ var game = {
if (!cc.macro.CLEANUP_IMAGE_CACHE && dynamicAtlasManager) {
dynamicAtlasManager.enabled = true;
}
// Disable dynamicAtlasManager to fix rendering residue for transparent images on Chrome69.
if (dynamicAtlasManager && cc.sys.browserType === cc.sys.BROWSER_TYPE_CHROME && parseFloat(cc.sys.browserVersion) >= 69.0) {
dynamicAtlasManager.enabled = false;
}
}
if (!this._renderContext) {
this.renderType = this.RENDER_TYPE_CANVAS;
Expand Down
4 changes: 2 additions & 2 deletions cocos2d/core/CCNode.js
Expand Up @@ -1134,7 +1134,7 @@ let NodeDefines = {
this._localZOrder = (this._localZOrder & 0x0000ffff) | (value << 16);

if (this._parent) {
this._parent._delaySort();
this._onSiblingIndexChanged();
}
}
}
Expand Down Expand Up @@ -1190,7 +1190,7 @@ let NodeDefines = {

// OVERRIDES

_onSiblingIndexChanged (index) {
_onSiblingIndexChanged () {
// update rendering scene graph, sort them by arrivalOrder
var parent = this._parent;
var siblings = parent._children;
Expand Down
14 changes: 9 additions & 5 deletions cocos2d/core/assets/CCTexture2D.js
Expand Up @@ -644,11 +644,7 @@ var Texture2D = cc.Class({
this.emit("load");

if (cc.macro.CLEANUP_IMAGE_CACHE && this._image instanceof HTMLImageElement) {
// wechat game platform will cache image parsed data,
// so image will consume much more memory than web, releasing it
this._image.src = "";
// Release image in loader cache
cc.loader.removeItem(this._image.id);
this._clearImage();
}
},

Expand Down Expand Up @@ -903,6 +899,14 @@ var Texture2D = cc.Class({

_isCompressed () {
return this._texture && this._texture._compressed;
},

_clearImage () {
// wechat game platform will cache image parsed data,
// so image will consume much more memory than web, releasing it
this._image.src = "";
// Release image in loader cache
cc.loader.removeItem(this._image.id);
}
});

Expand Down
21 changes: 11 additions & 10 deletions cocos2d/core/components/CCButton.js
Expand Up @@ -422,12 +422,13 @@ let Button = cc.Class({
// // Restore button status
let target = this._getTarget();
let transition = this.transition;
let originalScale = this._originalScale;

if (transition === Transition.COLOR && this.interactable) {
this._setTargetColor(this.normalColor);
}
else if (transition === Transition.SCALE && this._originalScale) {
target.scaleX = this._originalScale.x;
target.scaleY = this._originalScale.y;
else if (transition === Transition.SCALE && originalScale) {
target.setScale(originalScale.x, originalScale.y);
}
this._transitionFinished = true;
},
Expand Down Expand Up @@ -656,19 +657,19 @@ let Button = cc.Class({
let touch = event.touch;
let hit = this.node._hitTest(touch.getLocation());
let target = this._getTarget();
let originalScale = this._originalScale;

if (this.transition === Transition.SCALE && this._originalScale) {
if (this.transition === Transition.SCALE && originalScale) {
if (hit) {
this._fromScale.x = this._originalScale.x;
this._fromScale.y = this._originalScale.y;
this._toScale.x = this._originalScale.x * this.zoomScale;
this._toScale.y = this._originalScale.y * this.zoomScale;
this._fromScale.x = originalScale.x;
this._fromScale.y = originalScale.y;
this._toScale.x = originalScale.x * this.zoomScale;
this._toScale.y = originalScale.y * this.zoomScale;
this._transitionFinished = false;
} else {
this.time = 0;
this._transitionFinished = true;
target.scaleX = this._originalScale.x;
target.scaleY = this._originalScale.y;
target.setScale(originalScale.x, originalScale.y);
}
} else {
let state;
Expand Down
3 changes: 2 additions & 1 deletion cocos2d/core/components/CCComponent.js
Expand Up @@ -176,7 +176,8 @@ var Component = cc.Class({
}
}
},
visible: false
visible: false,
animatable: true
},

/**
Expand Down
103 changes: 77 additions & 26 deletions cocos2d/core/components/CCLabel.js
Expand Up @@ -126,6 +126,27 @@ const Overflow = cc.Enum({
* @property {Number} SystemFont
*/

/**
* !#en Do not do any caching.
* !#zh 不做任何缓存。
* @property {Number} NONE
*/
/**
* !#en In BITMAP mode, cache the label as a static image and add it to the dynamic atlas for batch rendering, and can batching with Sprites using broken images.
* !#zh BITMAP 模式,将 label 缓存成静态图像并加入到动态图集,以便进行批次合并,可与使用碎图的 Sprite 进行合批(注:动态图集在 Chrome 以及微信小游戏暂时关闭,该功能无效)。
* @property {Number} BITMAP
*/
/**
* !#en In CHAR mode, split text into characters and cache characters into a dynamic atlas which the size of 2048*2048.
* !#zh CHAR 模式,将文本拆分为字符,并将字符缓存到一张单独的大小为 2048*2048 的图集中进行重复使用,不再使用动态图集(注:当图集满时将不再进行缓存,暂时不支持 SHRINK 自适应文本尺寸(后续完善))。
* @property {Number} CHAR
*/
const CacheMode = cc.Enum({
NONE: 0,
BITMAP: 1,
CHAR: 2,
});

/**
* !#en The Label Component.
* !#zh 文字标签组件
Expand All @@ -146,6 +167,7 @@ let Label = cc.Class({

this._frame = null;
this._ttfTexture = null;
this._letterTexture = null;
},

editor: CC_EDITOR && {
Expand Down Expand Up @@ -431,29 +453,32 @@ let Label = cc.Class({
}
},

//For compatibility with v2.0.x temporary reservation.
_batchAsBitmap: false,

/**
* !#en Whether cache label to static texture and draw in dynamicAtlas.
* !#zh 是否将label缓存成静态图像并加入到动态图集.(对于静态文本建议使用该选项,便于批次合并减少drawcall)
* @property {Boolean} batchAsBitmap
* !#en The cache mode of label. This mode only supports system fonts.
* !#zh 文本缓存模式, 该模式只支持系统字体。
* @property {Label.CacheMode} cacheMode
*/
batchAsBitmap: {
get () {
return this._batchAsBitmap;
},
set (value) {
if (this._batchAsBitmap === value) return;

this._batchAsBitmap = value;

if (!this._batchAsBitmap && !(this.font instanceof cc.BitmapFont)) {
cacheMode: {
default: CacheMode.NONE,
type: CacheMode,
tooltip: CC_DEV && 'i18n:COMPONENT.label.cacheMode',
notify (oldValue) {
if (this.cacheMode === oldValue) return;

if (oldValue === CacheMode.BITMAP && !(this.font instanceof cc.BitmapFont)) {
this._frame._resetDynamicAtlasFrame();
}
this._activateMaterial(true);
this._updateRenderData();

if (oldValue === CacheMode.CHAR) {
this._ttfTexture = null;
}

this._updateRenderData(true);
},
animatable: false,
tooltip: CC_DEV && 'i18n:COMPONENT.label.batch_as_bitmap',
animatable: false
},

_isBold: {
Expand All @@ -474,6 +499,15 @@ let Label = cc.Class({
HorizontalAlign: HorizontalAlign,
VerticalAlign: VerticalAlign,
Overflow: Overflow,
CacheMode: CacheMode,
},

onLoad () {
// For compatibility with v2.0.x temporary reservation.
if (this._batchAsBitmap && this.cacheMode === CacheMode.NONE) {
this.cacheMode = CacheMode.BITMAP;
this._batchAsBitmap = false;
}
},

onEnable () {
Expand Down Expand Up @@ -505,6 +539,7 @@ let Label = cc.Class({
onDestroy () {
this._assembler && this._assembler._resetAssemblerData && this._assembler._resetAssemblerData(this._assemblerData);
this._assemblerData = null;
this._letterTexture = null;
if (this._ttfTexture) {
this._ttfTexture.destroy();
this._ttfTexture = null;
Expand Down Expand Up @@ -559,8 +594,7 @@ let Label = cc.Class({
// TODO: old texture in material have been released by loader
self._frame._texture = spriteFrame._texture;
self._activateMaterial(force);

if (CC_EDITOR || force) {
if (force) {
self._assembler && self._assembler.updateRenderData(self);
}
};
Expand All @@ -578,18 +612,24 @@ let Label = cc.Class({
}
}
else {
if (!this._ttfTexture) {
this._ttfTexture = new cc.Texture2D();
this._assemblerData = this._assembler._getAssemblerData();
this._ttfTexture.initWithElement(this._assemblerData.canvas);
}

if (!this._frame) {
this._frame = new LabelFrame();
}

if (this.cacheMode === CacheMode.CHAR && cc.sys.browserType !== cc.sys.BROWSER_TYPE_WECHAT_GAME_SUB) {
this._letterTexture = this._assembler._getAssemblerData();
this._frame._refreshTexture(this._letterTexture);
} else if (!this._ttfTexture) {
this._ttfTexture = new cc.Texture2D();
this._assemblerData = this._assembler._getAssemblerData();
this._ttfTexture.initWithElement(this._assemblerData.canvas);
}

this._frame._refreshTexture(this._ttfTexture);

if (this.cacheMode !== CacheMode.CHAR) {
this._frame._refreshTexture(this._ttfTexture);
}

this._activateMaterial(force);

if (force) {
Expand All @@ -598,6 +638,17 @@ let Label = cc.Class({
}
},

_updateColor () {
let font = this.font;
if (font instanceof cc.BitmapFont) {
this._super();
}
else {
this._updateRenderData();
this.node._renderFlag &= ~RenderFlow.FLAG_COLOR;
}
},

_activateMaterial (force) {
let material = this.sharedMaterials[0];
if (material && !force) {
Expand Down

0 comments on commit 9c498d7

Please sign in to comment.