feat: 调整奖励渲染逻辑
This commit is contained in:
+6
-34
@@ -9,8 +9,6 @@ export default class Reward extends cc.Component {
|
||||
|
||||
@property(cc.Prefab)
|
||||
rewardNode: cc.Prefab = null;
|
||||
@property(cc.SpriteFrame)
|
||||
battlePassCoin: cc.SpriteFrame = null;
|
||||
actionOver: boolean;
|
||||
speedTime: number = 50;
|
||||
private originalTimeScale: number = 1; // 记录原始时间缩放比例
|
||||
@@ -23,17 +21,13 @@ export default class Reward extends cc.Component {
|
||||
}
|
||||
|
||||
start() {
|
||||
// ... 已有代码 ...
|
||||
this.node.on(cc.Node.EventType.TOUCH_END, this.onNodeClick, this);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点点击事件处理函数
|
||||
*/
|
||||
onNodeClick() {
|
||||
// console.log('Reward 节点被点击了', this.actionOver);
|
||||
// 这里可以添加点击后的具体逻辑
|
||||
if (this.actionOver == true) {
|
||||
cc.fx.AudioManager._instance.playEffect("anniu_little", null);
|
||||
if (this.callBack != null) {
|
||||
@@ -41,10 +35,6 @@ export default class Reward extends cc.Component {
|
||||
}
|
||||
this.node.destroy();
|
||||
}
|
||||
else {
|
||||
// 游戏整体加速
|
||||
// this.speedUpGame();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,13 +124,7 @@ export default class Reward extends cc.Component {
|
||||
// 查找 rewardNode 的子节点 icon
|
||||
const iconNode = rewardNode.getChildByName('icon');
|
||||
const rewardData = data[index];
|
||||
const rewardIcon = this.getOrCreateRewardIcon(iconNode,
|
||||
rewardData.battlePass && rewardData.type === 'coin'
|
||||
? { ...rewardData, spriteFrame: this.battlePassCoin } : rewardData);
|
||||
if (rewardData.battlePass && rewardData.type !== 'coin' && rewardData.type !== 'infinite_health') {
|
||||
const prefix = rewardNode.getChildByName('xnode');
|
||||
prefix.getComponent(cc.Sprite).spriteFrame = NumberToImage.publicFont.getSpriteFrame('big_cheng');
|
||||
}
|
||||
const rewardIcon = this.getOrCreateRewardIcon(iconNode, rewardData);
|
||||
if (rewardIcon) {
|
||||
rewardIcon.active = true;
|
||||
}
|
||||
@@ -148,16 +132,9 @@ export default class Reward extends cc.Component {
|
||||
if (rewardData.type == 'coin')
|
||||
NumberToImage.numberToImageNodesNumber(rewardData.count, 45, 5, "big_", label, true);
|
||||
else if (rewardData.type == 'infinite_health') {
|
||||
if (durationUnits || rewardData.battlePass) {
|
||||
this.renderDuration(label, rewardData.count);
|
||||
rewardNode.getChildByName('xnode').active = false;
|
||||
} else {
|
||||
NumberToImage.getTimeMargin2(rewardData.count, 45, "coins", label, true);
|
||||
if (rewardData.count > 3600) label.x -= 10;
|
||||
rewardNode.getChildByName('xnode').opacity = 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.renderDuration(label, rewardData.count);
|
||||
rewardNode.getChildByName('xnode').active = false;
|
||||
} else {
|
||||
NumberToImage.numberToImageNodesNumber(rewardData.count, 50, 15, "big_", label, true);
|
||||
const xnode = rewardNode.getChildByName('xnode');
|
||||
xnode.opacity = 0;
|
||||
@@ -175,8 +152,7 @@ export default class Reward extends cc.Component {
|
||||
xnode.x = label.x + (firstDigit.x - firstDigit.width * firstDigit.anchorX) * label.scaleX
|
||||
- 6 - xnode.width * (1 - xnode.anchorX) * xnode.scaleX;
|
||||
}
|
||||
if (rewardData.type !== 'infinite_health' || durationUnits || rewardData.battlePass)
|
||||
this.alignAmount(rewardNode, rewardData.type !== 'coin' && rewardData.type !== 'infinite_health');
|
||||
this.alignAmount(rewardNode, rewardData.type !== 'coin' && rewardData.type !== 'infinite_health');
|
||||
rewardNode.getChildByName('label').active = false;
|
||||
if (iconNode) {
|
||||
cc.tween(iconNode)
|
||||
@@ -188,8 +164,7 @@ export default class Reward extends cc.Component {
|
||||
rewardNode.getChildByName('label').active = true;
|
||||
if (rewardNode.getChildByName('xnode').opacity == 1) {
|
||||
rewardNode.getChildByName('xnode').opacity = 0;
|
||||
}
|
||||
else if (rewardNode.getChildByName('xnode').opacity != 255) {
|
||||
} else if (rewardNode.getChildByName('xnode').opacity != 255) {
|
||||
rewardNode.getChildByName('xnode').active = true;
|
||||
rewardNode.getChildByName('xnode').opacity = 255;
|
||||
}
|
||||
@@ -271,7 +246,4 @@ export default class Reward extends cc.Component {
|
||||
rewardIcon.setScale(rewardData.type === "cat_skin" ? 1.1 : 1);
|
||||
return rewardIcon;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -305,8 +305,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 84,
|
||||
"height": 95
|
||||
"width": 190,
|
||||
"height": 147
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -358,7 +358,7 @@
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "d22678f9-a73b-4c94-af07-62a134fd2d30"
|
||||
"__uuid__": "c331a597-3361-4765-8e44-9989c8e6648a"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 1,
|
||||
@@ -1356,8 +1356,8 @@
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 36,
|
||||
"height": 34
|
||||
"width": 31,
|
||||
"height": 32
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
@@ -1409,7 +1409,7 @@
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "fafa9ef2-f250-47c7-b198-49971d3a380d"
|
||||
"__uuid__": "1d8908e8-0fc8-41b9-86b3-82c56da62633"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 1,
|
||||
|
||||
Reference in New Issue
Block a user