Signed-off-by: szrpf <27185709@qq.com>

This commit is contained in:
szrpf 2023-05-16 23:45:56 +08:00
parent febbc662f0
commit b05afd86e7

View File

@ -73,7 +73,7 @@ export default class ActionShadow extends cc.Component {
this.updateShadowData(); this.updateShadowData();
} }
@property() @property()
private _opacity: number = 50; private _opacity: number = 100;
@property({ type: cc.Integer, min: 0, max: 255, slide: true, displayName: CC_DEV && '透明度' }) @property({ type: cc.Integer, min: 0, max: 255, slide: true, displayName: CC_DEV && '透明度' })
private get opacity(): number { return this._opacity; } private get opacity(): number { return this._opacity; }
private set opacity(value: number) { private set opacity(value: number) {
@ -87,7 +87,7 @@ export default class ActionShadow extends cc.Component {
protected start() { protected start() {
let shadowNodeName = this.node.name + '<ActionShadow>'; let shadowNodeName = this.node.name + '<ActionShadow>';
this.shadowNode = this.node.parent.getChildByName(shadowNodeName) this.shadowNode = this.node.parent.getChildByName(shadowNodeName);
if (!this.shadowNode) { if (!this.shadowNode) {
this.shadowNode = new cc.Node(shadowNodeName); this.shadowNode = new cc.Node(shadowNodeName);
this.shadowNode.setParent(this.node.parent); this.shadowNode.setParent(this.node.parent);
@ -147,6 +147,7 @@ export default class ActionShadow extends cc.Component {
data.actionName = this.model.currentClip.name; data.actionName = this.model.currentClip.name;
data.frameTime = this.model.getAnimationState(data.actionName).time; data.frameTime = this.model.getAnimationState(data.actionName).time;
} }
this.shadowNode['_updateWorldMatrix']();
matrix = this.shadowNode['_worldMatrix'].m; matrix = this.shadowNode['_worldMatrix'].m;
for (let i = this.shadowNum - 1; i >= 0; --i) { for (let i = this.shadowNum - 1; i >= 0; --i) {
let node = this.shadowNode.children[i]; let node = this.shadowNode.children[i];
@ -166,7 +167,7 @@ export default class ActionShadow extends cc.Component {
this.shadowNode.destroyAllChildren(); this.shadowNode.destroyAllChildren();
for (let i = 0, len = this.shadowNum; i < len; ++i) { for (let i = 0, len = this.shadowNum; i < len; ++i) {
let node = cc.instantiate(this.node); let node = cc.instantiate(this.node);
node.name = `${this.node.name}${i}`; node.name = this.node.name + i;
let cmps = node['_components']; let cmps = node['_components'];
for (let j = cmps.length - 1; j >= 0; --j) { for (let j = cmps.length - 1; j >= 0; --j) {
if (cmps[j] instanceof cc.RenderComponent) continue; if (cmps[j] instanceof cc.RenderComponent) continue;