From 0675a9fc8e4e233263d2b1ca1bd3a483e95f08c7 Mon Sep 17 00:00:00 2001 From: Jare Guo Date: Tue, 19 Apr 2016 14:11:10 +0800 Subject: [PATCH] add inited event for Game --- cocos2d/core/CCGame.js | 3 +++ jsb/jsb-game.js | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/cocos2d/core/CCGame.js b/cocos2d/core/CCGame.js index 110fceb87e..b8bd2b1aca 100644 --- a/cocos2d/core/CCGame.js +++ b/cocos2d/core/CCGame.js @@ -39,6 +39,7 @@ var game = /** @lends cc.game# */{ EVENT_HIDE: "game_on_hide", EVENT_SHOW: "game_on_show", EVENT_RESIZE: "game_on_resize", + EVENT_GAME_INITED: "game_inited", EVENT_RENDERER_INITED: "renderer_inited", RENDER_TYPE_CANVAS: 0, @@ -336,10 +337,12 @@ var game = /** @lends cc.game# */{ cc.loader.load(jsList, function (err) { if (err) throw new Error(JSON.stringify(err)); self._prepared = true; + self.emit(self.EVENT_GAME_INITED); if (cb) cb(); }); } else { + self.emit(self.EVENT_GAME_INITED); if (cb) cb(); } diff --git a/jsb/jsb-game.js b/jsb/jsb-game.js index b9469c2b3d..3256f1b2d9 100644 --- a/jsb/jsb-game.js +++ b/jsb/jsb-game.js @@ -40,6 +40,8 @@ cc.js.mixin(cc.game, { RENDER_TYPE_CANVAS: 0, RENDER_TYPE_WEBGL: 1, RENDER_TYPE_OPENGL: 2, + + EVENT_GAME_INITED: "game_inited", CONFIG_KEY: { width: 'width', @@ -105,10 +107,12 @@ cc.js.mixin(cc.game, { cc.loader.load(jsList, function (err) { if (err) throw new Error(JSON.stringify(err)); self._prepared = true; + self.emit(self.EVENT_GAME_INITED); if (cb) cb(); }); } else { + self.emit(self.EVENT_GAME_INITED); if (cb) cb(); }