1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import { _decorator, Component, Label, Node } from 'cc';
- import { gameManager } from '../gameManager';
- const { ccclass, property } = _decorator;
- @ccclass('dialog')
- export class dialog extends Component {
- @property(Node) lab_name;
- @property(Node) btn_yes;
- @property(Node) btn_one_yes;
- @property(Node) btn_not;
- private m_call_yes = null;
- private m_call_not = null;
- public show(text:string,call_yes,call_not){
- this.m_call_yes = call_yes;
- this.m_call_not = call_not;
- this.btn_yes.on(Node.EventType.TOUCH_START,()=>{
- gameManager.playBtnSound()
- if(this.m_call_yes!=null){
- this.m_call_yes()
- }
- this.close()
- },this);
- this.btn_not.on(Node.EventType.TOUCH_START,()=>{
- gameManager.playBtnSound()
- if(this.m_call_not!=null){
- this.m_call_not()
- }
- this.close()
- },this);
- this.lab_name.getComponent(Label).string = text;
- }
- public showOne(text:string,call_yes){
- this.m_call_yes = call_yes;
- this.btn_not.active = false;
- this.btn_yes.active = false;
- this.btn_one_yes.active = true;
- this.btn_one_yes.on(Node.EventType.TOUCH_START,()=>{
- gameManager.playBtnSound()
- if(this.m_call_yes!=null){
- this.m_call_yes()
- }
- this.close()
- },this);
- this.lab_name.getComponent(Label).string = text;
- }
- close(){
- this.node.removeFromParent()
- }
- }
|