1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import i18n from "../../../i18n/i18n";
- const {ccclass, property} = cc._decorator;
- /**
- * 对话框 - 对话
- */
- @ccclass
- export default class DialogSay extends cc.Component {
- @property(cc.Label)
- mContent: cc.Label = null;
- /**
- * 对话框
- */
- @property(cc.Node)
- mDialog: cc.Node = null;
- public index:number = 0;
- /**
- * 对话内容
- */
- private contents:Array<string> = null;
- public setContents(contents:Array<string>){
- this.contents = contents;
- this.mContent.string = i18n.t(this.contents[0]);
- this.index = 0;
- }
- /**
- * 对话结束回调
- */
- public endCallback:()=>void;
- public close(){
- this.node.destroy();
- }
- public setEndCallback(endCallback:()=>void){
- this.endCallback = endCallback;
- }
- public onclick(){
- this.index ++;
- if(this.index >= this.contents.length){
- this.endCallback();
- this.close();
- return;
- }
- this.mContent.string = i18n.t(this.contents[this.index]);
- }
- }
|