优化更新弹窗奖励窗口数字

This commit is contained in:
COMPUTER\EDY
2026-09-24 16:26:57 +08:00
parent 6a4990bb35
commit ad047b618a
6 changed files with 69 additions and 16 deletions
+50
View File
@@ -25,11 +25,15 @@ export default class NumberToImage extends cc.Component {
@property(cc.SpriteAtlas)
fontPassCheck: cc.SpriteAtlas = null;
@property(cc.SpriteAtlas)
publicFont: cc.SpriteAtlas = null;
static font: any = null;
static font2: any = null;
static font3: any = null;
static font4: any = null;
static fontPassCheck: any = null;
static publicFont: any = null;
// LIFE-CYCLE CALLBACKS:
onLoad() {
@@ -38,6 +42,8 @@ export default class NumberToImage extends cc.Component {
NumberToImage.font2 = this.fontUI2;
NumberToImage.font3 = this.fontUI3;
NumberToImage.font4 = this.fontUI4;
NumberToImage.publicFont = this.publicFont;
NumberToImage.fontPassCheck = this.fontPassCheck;
}
}
@@ -327,6 +333,50 @@ export default class NumberToImage extends cc.Component {
}
static numberToImageNodesNumber(number, width, posX, name, targetNode: cc.Node, middle: boolean = false) {
const numStr = number.toString();
let cha = 0;
if (number > 99) cha = -posX
else if (number < 10) cha = posX
if (targetNode) {
if (targetNode.children) {
if (targetNode.children.length > 0)
targetNode.removeAllChildren();
}
}
const digitNodes: cc.Node[] = [];
for (let i = 0; i < numStr.length; i++) {
const digit = parseInt(numStr[i], 10);
const node = new cc.Node();
const sprite = node.addComponent(cc.Sprite);
sprite.spriteFrame = this.publicFont._spriteFrames[name + digit + ""];
digitNodes.push(node);
}
// 计算总宽度
const totalWidth = (numStr.length - 1) * width + (digitNodes[0]?.width || 0);
if (middle) {
// 计算居中的起始位置
const startX = -totalWidth / 2;
for (let i = 0; i < digitNodes.length; i++) {
const node = digitNodes[i];
node.x = startX + i * width;
if (targetNode) node.parent = targetNode;
}
} else {
for (let i = 0; i < digitNodes.length; i++) {
const node = digitNodes[i];
node.x = i * width + cha;
if (targetNode) node.parent = targetNode;
}
}
}
static numberToImageNodesShop(number, width, posX, name, targetNode: cc.Node, middle: boolean = false) {
const numStr = number.toString();
let cha = 0;
+2 -2
View File
@@ -137,14 +137,14 @@ export default class Reward extends cc.Component {
}
let label = rewardNode.getChildByName('label')
if (rewardData.type == 'coin')
NumberToImage.numberToImageNodes(rewardData.count, 45, 5, "coins", label, true);
NumberToImage.numberToImageNodesNumber(rewardData.count, 45, 5, "big_", label, true);
else if (rewardData.type == 'infinite_health') {
NumberToImage.getTimeMargin2(rewardData.count, 45, "coins", label, true);
if (rewardData.count > 3600) label.x -= 10;
rewardNode.getChildByName('xnode').opacity = 1;
}
else {
NumberToImage.numberToImageNodes(rewardData.count, 50, 15, "coins", label, true);
NumberToImage.numberToImageNodesNumber(rewardData.count, 50, 15, "big_", label, true);
rewardNode.getChildByName('xnode').opacity = 0;
label.x += 20;
}
+1 -1
View File
@@ -757,7 +757,7 @@ export class GameConfig {
vibrateOpen: true, //震动
coinnum: 0, //每局的金币数
paid_user: false, //是否是付费用户
version: "1.0.70", //版本号
version: "1.0.71", //版本号
shushu_DistinctId: "", //数数访客ID
shushu_AccountId: "", //数数账号ID
uid: "", //用户和后端唯一id