cocos-enhance-kit/patches/v1.0.0/0011-.patch
2022-06-21 23:22:06 +08:00

147 lines
5.2 KiB
Diff

From 25a82582da7f743d769fbfb136bb4c5c9713e3e2 Mon Sep 17 00:00:00 2001
From: SmallMain <smallmain@outlook.com>
Date: Tue, 21 Jun 2022 15:36:05 +0800
Subject: [PATCH 11/15] =?UTF-8?q?=E5=A4=9A=E7=BA=B9=E7=90=86=E6=B8=B2?=
=?UTF-8?q?=E6=9F=93=E3=80=81=E5=8A=A8=E6=80=81=E5=9B=BE=E9=9B=86=E5=BC=80?=
=?UTF-8?q?=E5=85=B3=E6=97=B6=E4=B8=BB=E5=8A=A8=E5=88=B7=E6=96=B0=E6=B8=B2?=
=?UTF-8?q?=E6=9F=93=E7=8A=B6=E6=80=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
engine/cocos2d/core/components/CCLabel.js | 9 +++++++++
.../cocos2d/core/components/CCMotionStreak.js | 12 ++++++++++++
engine/cocos2d/core/components/CCSprite.js | 8 ++++++++
engine/extensions/spine/Skeleton.js | 18 ++++++++++++++++--
4 files changed, 45 insertions(+), 2 deletions(-)
diff --git a/engine/cocos2d/core/components/CCLabel.js b/engine/cocos2d/core/components/CCLabel.js
index b672f23..6cbfe1b 100644
--- a/engine/cocos2d/core/components/CCLabel.js
+++ b/engine/cocos2d/core/components/CCLabel.js
@@ -586,15 +586,24 @@ let Label = cc.Class({
autoSwitchMaterial: {
type: RenderComponent.EnableType,
default: RenderComponent.EnableType.GLOBAL,
+ notify(oldValue) {
+ if (this.autoSwitchMaterial === oldValue) return;
+ this.setVertsDirty();
+ },
},
allowDynamicAtlas: {
type: RenderComponent.EnableType,
default: RenderComponent.EnableType.GLOBAL,
+ notify(oldValue) {
+ if (this.allowDynamicAtlas === oldValue) return;
+ this.setVertsDirty();
+ },
},
enableRetina: {
type: RenderComponent.EnableType,
default: RenderComponent.EnableType.GLOBAL,
notify(oldValue) {
+ if (this.enableRetina === oldValue) return;
this.setVertsDirty();
}
},
diff --git a/engine/cocos2d/core/components/CCMotionStreak.js b/engine/cocos2d/core/components/CCMotionStreak.js
index 545c03f..7205e94 100644
--- a/engine/cocos2d/core/components/CCMotionStreak.js
+++ b/engine/cocos2d/core/components/CCMotionStreak.js
@@ -218,9 +218,21 @@ var MotionStreak = cc.Class({
autoSwitchMaterial: {
type: RenderComponent.EnableType,
default: RenderComponent.EnableType.GLOBAL,
+ notify(oldValue) {
+ if (this.autoSwitchMaterial === oldValue) return;
+ this.setVertsDirty();
+ },
},
},
+ setVertsDirty() {
+ // 自动切换材质
+ this._checkSwitchMaterial();
+
+ this._updateMaterial();
+ this._super();
+ },
+
__preload() {
this._super();
this._checkSwitchMaterial();
diff --git a/engine/cocos2d/core/components/CCSprite.js b/engine/cocos2d/core/components/CCSprite.js
index 806a50d..45debb3 100644
--- a/engine/cocos2d/core/components/CCSprite.js
+++ b/engine/cocos2d/core/components/CCSprite.js
@@ -388,10 +388,18 @@ var Sprite = cc.Class({
autoSwitchMaterial: {
type: RenderComponent.EnableType,
default: RenderComponent.EnableType.GLOBAL,
+ notify(oldValue) {
+ if (this.autoSwitchMaterial === oldValue) return;
+ this.setVertsDirty();
+ },
},
allowDynamicAtlas: {
type: RenderComponent.EnableType,
default: RenderComponent.EnableType.GLOBAL,
+ notify(oldValue) {
+ if (this.allowDynamicAtlas === oldValue) return;
+ this.setVertsDirty();
+ },
},
},
diff --git a/engine/extensions/spine/Skeleton.js b/engine/extensions/spine/Skeleton.js
index 42046fc..61cde65 100644
--- a/engine/extensions/spine/Skeleton.js
+++ b/engine/extensions/spine/Skeleton.js
@@ -432,10 +432,18 @@ sp.Skeleton = cc.Class({
autoSwitchMaterial: {
type: RenderComponent.EnableType,
default: RenderComponent.EnableType.GLOBAL,
+ notify(oldValue) {
+ if (this.autoSwitchMaterial === oldValue) return;
+ this.setVertsDirty();
+ },
},
allowDynamicAtlas: {
type: RenderComponent.EnableType,
default: RenderComponent.EnableType.GLOBAL,
+ notify(oldValue) {
+ if (this.allowDynamicAtlas === oldValue) return;
+ this.setVertsDirty();
+ },
},
},
@@ -455,6 +463,13 @@ sp.Skeleton = cc.Class({
this._dataDirty = true;
},
+ setVertsDirty() {
+ this.invalidAnimationCache();
+ this._dataDirty = true;
+ this._materialCache = {};
+ this._super();
+ },
+
// override base class _getDefaultMaterial to modify default material
_getDefaultMaterial () {
return cc.Material.getBuiltinMaterial('2d-spine');
@@ -1005,8 +1020,7 @@ sp.Skeleton = cc.Class({
attachment.setRegion(region);
attachment.updateOffset();
}
- this._dataDirty = true;
- this.invalidAnimationCache();
+ this.setVertsDirty();
return true;
}
return false;
--
2.32.0 (Apple Git-132)