更新图片素材,修复合并BUG
This commit is contained in:
@@ -19,12 +19,16 @@ export default class NumberToImage extends cc.Component {
|
||||
@property(cc.SpriteAtlas)
|
||||
fontUI3: cc.SpriteAtlas = null;
|
||||
|
||||
@property(cc.SpriteAtlas)
|
||||
fontUI4: cc.SpriteAtlas = null;
|
||||
|
||||
@property(cc.SpriteAtlas)
|
||||
fontPassCheck: cc.SpriteAtlas = null;
|
||||
|
||||
static font: any = null;
|
||||
static font2: any = null;
|
||||
static font3: any = null;
|
||||
static font4: any = null;
|
||||
static fontPassCheck: any = null;
|
||||
// LIFE-CYCLE CALLBACKS:
|
||||
|
||||
@@ -33,6 +37,7 @@ export default class NumberToImage extends cc.Component {
|
||||
NumberToImage.font = this.fontUI;
|
||||
NumberToImage.font2 = this.fontUI2;
|
||||
NumberToImage.font3 = this.fontUI3;
|
||||
NumberToImage.font4 = this.fontUI4;
|
||||
NumberToImage.fontPassCheck = this.fontPassCheck;
|
||||
}
|
||||
}
|
||||
@@ -240,6 +245,8 @@ export default class NumberToImage extends cc.Component {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static numberToImageNodes6(number, width, posX, name, targetNode: cc.Node, middle: boolean = false) {
|
||||
const numStr = number.toString();
|
||||
let cha = 0;
|
||||
@@ -278,6 +285,48 @@ export default class NumberToImage extends cc.Component {
|
||||
}
|
||||
}
|
||||
|
||||
static numberToImageNodesCoin(number, width, posX, name, targetNode: cc.Node, middle: boolean = false) {
|
||||
if (targetNode) {
|
||||
const numStr = number.toString();
|
||||
let cha = 0;
|
||||
if (number > 99) cha = -posX
|
||||
else if (number < 10) cha = posX
|
||||
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.font4._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;
|
||||
|
||||
Reference in New Issue
Block a user