first commit
This commit is contained in:
48
assets/seripts/libs/EventDispatcher.ts
Normal file
48
assets/seripts/libs/EventDispatcher.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { _decorator, Component, EventTarget } from "cc";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
const event_target = new EventTarget();
|
||||
|
||||
export class EventDispatcher {
|
||||
private static data: EventDispatcher;
|
||||
|
||||
// 小恐龙吃到音符事件
|
||||
public static readonly DINO_EAT_NOTE = "dino_eat_note";
|
||||
// 音符碰到线事件
|
||||
public static readonly UPDATE_LIFE = "update_life";
|
||||
// 开始游戏事件
|
||||
public static readonly GAME_STAET = "game_start";
|
||||
|
||||
// 游戏结束事件
|
||||
public static readonly GAME_OVER = "game_over";
|
||||
// 游戏闯关成功事件
|
||||
public static readonly PASS_LEVLE = "pass_levle";
|
||||
|
||||
// 暂停事件
|
||||
public static readonly GAME_PAUSE = "game_pause";
|
||||
// 继续游戏事件
|
||||
public static readonly GAME_RESUME = "game_resume";
|
||||
// 清除所有音符事件
|
||||
public static readonly CLEAR_ALL_NOTE = "clear_all_note";
|
||||
// 清楚可视区域的音符事件
|
||||
public static readonly CLEAR_SCREEN_NOTE = "clear_screen_note";
|
||||
// 移动小恐龙到线的位置事件
|
||||
public static readonly MOVE_DINO_TO_LINE = "move_dino_to_line";
|
||||
// 显示结果弹窗事件
|
||||
public static readonly SHOW_RESULT_MODAL = "show_result_modal";
|
||||
// 显示暂停弹窗事件
|
||||
public static readonly SHOW_PAUSE_MODAL = "show_pause_modal";
|
||||
// 显示继续游戏弹窗事件
|
||||
public static readonly SHOW_CONTINUE_MODAL = "show_continue_modal";
|
||||
|
||||
static getTarget() {
|
||||
if (EventDispatcher.data == null) {
|
||||
EventDispatcher.data = new EventDispatcher();
|
||||
}
|
||||
return EventDispatcher.data.getEventTarget();
|
||||
}
|
||||
|
||||
private getEventTarget(): EventTarget {
|
||||
return event_target;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user