/* * @Author: WoNiu * @Date: 2024-03-21 13:28:47 * @LastEditTime: 2024-03-24 16:49:37 * @LastEditors: WoNiu * @Description: */ /* * @Author: WoNiu * @Date: 2024-03-21 13:28:47 * @LastEditTime: 2024-03-22 21:24:13 * @LastEditors: WoNiu * @Description: 顺序选择卡片节点 */ import { _decorator, Node, } from "cc"; import { BaseSprite } from "../../GlobalScript/CommonComponent/BaseSprite"; import { NpkImage } from "../../Tool/NPKImage"; import { BaseButtonAction } from "../../GlobalScript/CommonComponent/BaseButtonAction"; import { CardNode } from "./CardNode"; import { TimingProgressBar } from "../Common/TimingProgressBar"; const { ccclass, property } = _decorator; /// 选择顺序卡牌Node @ccclass("SelectNumberNode") export class SelectNumberNode extends Node { oneCard: CardNode; twoCard: CardNode; threeCard: CardNode; constructor() { super(); this.initBackground(); this.initCards(); this.initTiming(); } initBackground() { const node = new Node(); node.setPosition(184.5, -181.5); const bs = node.addComponent(BaseSprite); bs.updateSpriteFrame(NpkImage.ingame, 46); this.addChild(node); } initCards() { this.oneCard = new CardNode(); this.oneCard.setPosition(339, -220); this.addChild(this.oneCard); const Onebba = this.oneCard.addComponent(BaseButtonAction); Onebba.onMouseLeftDown = ()=>{ this.onMouseLeftDown(0) }; this.twoCard = new CardNode(); this.twoCard.setPosition(533.5, -220); this.addChild(this.twoCard); const twoBba = this.twoCard.addComponent(BaseButtonAction); twoBba.onMouseLeftDown = ()=>{ this.onMouseLeftDown(1) }; this.threeCard = new CardNode(); this.threeCard.setPosition(728, -220); this.addChild(this.threeCard); const threeBba = this.threeCard.addComponent(BaseButtonAction); threeBba.onMouseLeftDown = ()=>{ this.onMouseLeftDown(2) }; } initTiming(){ const time = new TimingProgressBar(); this.addChild(time); time.tweenerStart(3,()=>{ console.log('缓动完成'); this.flipsCard(); }); } //* 翻转卡片 flipsCard(){ const cards = [this.oneCard,this.twoCard,this.threeCard]; for (let i = 0; i < cards.length; i++) { const card = cards[i]; card.Disable = true; card.flipsAnimation.animationStart(i,'玩家' + i); } } onMouseLeftDown(tag:number){ const cards = [this.oneCard,this.twoCard,this.threeCard]; cards.forEach((card)=>{ card.Disable = true; }); }; update(deltaTime: number) {} }