import { _decorator, Component, EventTouch, Node, NodeEventType } from 'cc'; const { ccclass, property } = _decorator; @ccclass('ShowInfoCom') export class ShowInfoCom extends Component { protected onLoad(): void { this.node.on(NodeEventType.TOUCH_START, this.onTouchMove, this); this.node.on(NodeEventType.TOUCH_MOVE, this.onTouchMove, this); this.node.on(NodeEventType.TOUCH_END, this.onTouchEnd, this); this.node.on(NodeEventType.TOUCH_CANCEL, this.onTouchEnd, this); // oops.message.on("active_card_eid", this.do_active_card_eid, this); } start() { } onTouchMove(event: EventTouch) { let delta = event.getDelta(); this.node.setPosition(this.node.position.x+delta.x,this.node.position.y+delta.y); this.show_info() } show_info(uuid:number,card_type:number){ console.log("show_info",this.card_uid) let parent = this.node.parent.parent let node =parent.getChildByName("item_box") if(this.card_type == 2){ smc.vm_data.item_box.info = SkillSet[this.card_uid].info smc.vm_data.item_box.name = SkillSet[this.card_uid].name smc.vm_data.item_box.skillcd = SkillSet[this.card_uid].cd smc.vm_data.item_box.skillsd = SkillSet[this.card_uid].sd smc.vm_data.item_box.atk = SkillSet[this.card_uid].atk smc.vm_data.item_box.hp = SkillSet[this.card_uid].hp node.active=true } if(this.card_type == 3){ console.log(SkillSet[this.card_uid]) smc.vm_data.item_box.info = SkillSet[this.card_uid].info smc.vm_data.item_box.name = SkillSet[this.card_uid].name smc.vm_data.item_box.skillcd = SkillSet[this.card_uid].cd smc.vm_data.item_box.skillsd = SkillSet[this.card_uid].sd smc.vm_data.item_box.atk = SkillSet[this.card_uid].atk smc.vm_data.item_box.hp = SkillSet[this.card_uid].hp smc.vm_data.item_box.shield = SkillSet[this.card_uid].shield node.active=true if(SkillSet[this.card_uid].shield > 0){ node.getChildByName("data").getChildByName("shield").active=true } if(SkillSet[this.card_uid].hp > 0){ node.getChildByName("data").getChildByName("hp").active=true } } } onTouchEnd(){ if(this.node.position.y-this.pos_y > 150){ this.use_card() }else{ this.node.setPosition(this.pos_x,this.pos_y); } let parent = this.node.parent.parent let node = parent.getChildByName("item_box") node.active=false node.getChildByName("data").getChildByName("shield").active=false node.getChildByName("data").getChildByName("hp").active=false } update(deltaTime: number) { } }