ui图的使用

This commit is contained in:
TJH 2025-12-03 16:20:46 +08:00
parent a6279706a4
commit 7dfb7c8226
6 changed files with 5701 additions and 2927 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
import { _decorator, Animation, Button, Component, Label, Layout, Node, ParticleSystem, Prefab, RichText, Size, sp, Sprite, tween, UITransform, v3, Vec3 } from 'cc';
import { _decorator, Animation, Button, Component, Label, Layout, Node, ParticleSystem, Prefab, RichText, Size, sp, Sprite, SpriteFrame, tween, UITransform, v3, Vec3 } from 'cc';
import { RollerManager } from './game/RollerManager';
import { GameInfo, ICON_RATE, ROLLER_COMBINE_EVENT, SLOT_GAME_EVENT, WIN_TYPE } from './game/Define';
import { Icon, IconEventBus } from './game/Icon';
@ -19,6 +19,9 @@ export class SlotGame extends Component {
@property(Prefab)
iconMsgPre: Prefab = null;
@property([SpriteFrame])
multiFrame = new Array<SpriteFrame>;
// 跑马灯信息
private moveSprite: Sprite[] = [];
private startPos: Vec3 = new Vec3(540, 0, 0);
@ -50,7 +53,7 @@ export class SlotGame extends Component {
private base: Node = null;
private normalMultiAni: Animation = null;
private multiLabel: Label = null;
private multi: Node = null;
private waysCount: Label = null;
private waysLayout: Layout = null;
private layCount: Label = null;
@ -111,7 +114,7 @@ export class SlotGame extends Component {
this.base = this.node.getChildByName('base');
this.normalMultiAni = this.base.getChildByName('NormalMultiAniNode').getComponent(Animation);
this.multiLabel = this.base.getChildByName('multi').getComponent(Label);
this.multi = this.base.getChildByName('multi');
let ways = this.base.getChildByName('ways');
this.waysCount = ways.getChildByName('count').getComponent(Label);
this.waysLayout = ways.getChildByName('lay').getComponent(Layout);
@ -223,7 +226,7 @@ export class SlotGame extends Component {
AudioManager.instance.playSFX('Spin_Button_Click');
this.setWaysCount('...');
if (!isFree) {
this.setMultiLabel(1);
this.setMultiLabel([2, 2, 2, 2]);
}
this.showWinScore(false, false, false, false, false);
this.rollerManager.resetInfo();
@ -243,9 +246,16 @@ export class SlotGame extends Component {
this.rollerManager.stopScroll(this.spinData);
}
setMultiLabel(multi: number) {
this.multiLabel.string = `x${multi}`;
this.freeMultiLabel.string = `x${multi}`;
setMultiLabel(multiArr: Array<number>) {
this.multi.children[4].getChildByName('Label').getComponent(Label).string = 'x' + (multiArr[3] + 2)
for (let i = 0; i < this.multi.children.length - 1; i++) {
this.multi.children[i].getChildByName('Label').getComponent(Label).string = 'x' + multiArr[i]
this.multi.children[i].getComponent(Sprite).spriteFrame = multiArr[i] > 2 ? this.multiFrame[1] : this.multiFrame[0]
}
// this.multi.string = `x${multi}`;
// this.freeMultiLabel.string = `x${multi}`;
}
setWaysCount(ways: any) {
@ -553,11 +563,11 @@ export class SlotGame extends Component {
}
playNormalMultiAni(isSwitch: boolean) {
if (isSwitch) {
this.normalMultiAni.play('NM_multiVFX_switch_animation');
} else {
this.normalMultiAni.play('NM_multiVFX_win_animation');
}
// if (isSwitch) {
// this.normalMultiAni.play('NM_multiVFX_switch_animation');
// } else {
// this.normalMultiAni.play('NM_multiVFX_win_animation');
// }
}
playFreeMultiAni() {

View File

@ -213,7 +213,7 @@ export class SlotScene extends Component {
AudioManager.instance.playBGM("Normal_Mode_BGM");
}
this.slotGame.setWaysCount(this.spinData.Symbol.WaysNum);
this.slotGame.setMultiLabel(this.spinData.WinMultiPlier);
this.slotGame.setMultiLabel(this.spinData.Symbol.MultiValue);
this.slotGame.setRollerIconRule(rollerIconRule);
let frb = GameDataManager.instance.frb;
@ -577,7 +577,7 @@ export class SlotScene extends Component {
} else {
this.slotGame.playNormalMultiAni(true);
}
this.slotGame.setMultiLabel(this.spinData.WinMultiPlier);
this.slotGame.setMultiLabel(this.spinData.Symbol.MultiValue);
// 创建新图标
this.slotGame.createNewIconTop(this.spinData);
} catch (error) {

View File

@ -1,4 +1,4 @@
import { _decorator, Component, Mask, Node, Sprite, SpriteFrame, UITransform, v3, Vec3 } from 'cc';
import { _decorator, Component, Mask, Node, Sprite, SpriteFrame, UITransform, UITransformComponent, v3, Vec3 } from 'cc';
import { IconFactory } from './IconFactory';
import { Roller } from './Roller';
import { GameData, ICON_HEIGHT, ICON_WIDTH, ROLLER_COMBINE_EVENT, ROLLER_EVENT } from './Define';
@ -23,9 +23,6 @@ export class RollerManager extends Component {
@property({ type: IconFactory, tooltip: '图标工厂' })
iconFactory: IconFactory = null;
@property(SpriteFrame)
vMaskSpriteFrame: SpriteFrame = null;
rollerMsg: any[] = [
{ row: 5, col: 1 },
{ row: 5, col: 1 },
@ -74,7 +71,7 @@ export class RollerManager extends Component {
this.allRollers = [];
this.vRollers = [];
this.vMaskNode = this.createMaskNode('VMask', this.vMaskSpriteFrame);
this.vMaskNode = this.createMaskNode('VMask');
this.node.addChild(this.vMaskNode);
@ -108,18 +105,20 @@ export class RollerManager extends Component {
}
}
private createMaskNode(name: string, spriteFrame: SpriteFrame): Node {
private createMaskNode(name: string): Node {
let maskNode = new Node();
maskNode.name = name;
let comp = maskNode.addComponent(Mask);
comp.type = Mask.Type.SPRITE_STENCIL;
let UITransform = maskNode.addComponent(UITransformComponent);
comp.type = Mask.Type.GRAPHICS_RECT;
let spriteCom = maskNode.getComponent(Sprite);
spriteCom.spriteFrame = spriteFrame;
spriteCom.sizeMode = Sprite.SizeMode.TRIMMED;
spriteCom.trim = true;
UITransform.setContentSize(1040, 840)
// let spriteCom = maskNode.getComponent(Sprite);
// spriteCom.spriteFrame = spriteFrame;
// spriteCom.sizeMode = Sprite.SizeMode.CUSTOM;
// spriteCom.trim = true;
return maskNode;
}

View File

@ -1,6 +1,5 @@
import { _decorator, Component, EventMouse, JsonAsset, Label, Layout, math, Node, ScrollView, UITransform } from 'cc';
import { getAllRichTexts, hideToBottom, isBrahmic, updateLang, wrapTextBySpace } from './Tools';
import { Data } from './Data';
import { getCsymbol, getLanguage } from 'db://assets/Loading/scripts/comm';
const { ccclass, property } = _decorator;

View File

@ -310,7 +310,7 @@
"a": 255
},
"_spriteFrame": {
"__uuid__": "2eb826ea-e65b-40e2-bea0-186d3c5889c4@f9941",
"__uuid__": "7bc4f08b-8916-4cba-bd93-ff6a63a9a992@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,