64 lines
1.5 KiB
TypeScript
64 lines
1.5 KiB
TypeScript
import { _decorator, Node, Button } from 'cc';
|
|
import { BaseView } from 'db://assets/scripts/core/BaseView';
|
|
import { ViewManager } from 'db://assets/scripts/core/ViewManager';
|
|
const { ccclass, property } = _decorator;
|
|
|
|
/**
|
|
* 写关卡/分享页面组件
|
|
* 用于展示用户已通关的关卡列表,选择关卡进行分享
|
|
*/
|
|
@ccclass('PageWriteLevels')
|
|
export class PageWriteLevels extends BaseView {
|
|
@property({ type: Node, tooltip: '返回按钮' })
|
|
backBtn: Node | null = null;
|
|
|
|
/**
|
|
* 页面首次加载时调用
|
|
*/
|
|
onViewLoad(): void {
|
|
console.log('[PageWriteLevels] onViewLoad');
|
|
this._initButtons();
|
|
}
|
|
|
|
/**
|
|
* 初始化按钮事件
|
|
*/
|
|
private _initButtons(): void {
|
|
if (this.backBtn) {
|
|
this.backBtn.on(Button.EventType.CLICK, this._onBackClick, this);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 返回按钮点击回调
|
|
*/
|
|
private _onBackClick(): void {
|
|
console.log('[PageWriteLevels] 返回按钮点击');
|
|
ViewManager.instance.back();
|
|
}
|
|
|
|
/**
|
|
* 页面每次显示时调用
|
|
*/
|
|
onViewShow(): void {
|
|
console.log('[PageWriteLevels] onViewShow');
|
|
}
|
|
|
|
/**
|
|
* 页面隐藏时调用
|
|
*/
|
|
onViewHide(): void {
|
|
console.log('[PageWriteLevels] onViewHide');
|
|
}
|
|
|
|
/**
|
|
* 页面销毁时调用
|
|
*/
|
|
onViewDestroy(): void {
|
|
console.log('[PageWriteLevels] onViewDestroy');
|
|
if (this.backBtn) {
|
|
this.backBtn.off(Button.EventType.CLICK, this._onBackClick, this);
|
|
}
|
|
}
|
|
}
|