diff --git a/src/egret/context/MainContext.ts b/src/egret/context/MainContext.ts index 833bcab02d..caf616c831 100644 --- a/src/egret/context/MainContext.ts +++ b/src/egret/context/MainContext.ts @@ -26,12 +26,12 @@ */ -module egret{ +module egret { /** - * @class egret.MainContext - * @classdesc + * @class egret.MainContext + * @classdesc * MainContext是游戏的核心跨平台接口,组合了多个功能Context,并是游戏启动的主入口 - * @extends egret.EventDispatcher + * @extends egret.EventDispatcher */ export class MainContext extends EventDispatcher { @@ -41,31 +41,31 @@ module egret{ /** * 渲染Context - * @member egret.MainContext#rendererContext + * @member egret.MainContext#rendererContext */ public rendererContext:RendererContext; /** * 触摸Context - * @member egret.MainContext#touchContext + * @member egret.MainContext#touchContext */ public touchContext:TouchContext; /** * 网络Context - * @member egret.MainContext#netContext + * @member egret.MainContext#netContext */ public netContext:NetContext; /** * 设备divice - * @member egret.MainContext#deviceContext + * @member egret.MainContext#deviceContext */ public deviceContext:DeviceContext; /** * 舞台 - * @member egret.MainContext#stage + * @member egret.MainContext#stage */ public stage:Stage; @@ -76,7 +76,7 @@ module egret{ /** * 游戏启动,开启主循环,参考Flash的滑动跑道模型 - * @method egret.MainContext#run + * @method egret.MainContext#run */ public run() { Ticker.getInstance().run(); @@ -93,7 +93,7 @@ module egret{ var context = this.rendererContext; context.clearScreen(); - if(__callLaterFunctionList.length>0){ + if (__callLaterFunctionList.length > 0) { var functionList:Array = __callLaterFunctionList; __callLaterFunctionList = []; var thisList:Array = __callLaterThisList; @@ -103,12 +103,12 @@ module egret{ } this.dispatchEventWith(Event.RENDER); - if(Stage._invalidateRenderFlag){ + if (Stage._invalidateRenderFlag) { this.broadcastRender(); Stage._invalidateRenderFlag = false; } - if(functionList){ - this.doCallLaterList(functionList,thisList,argsList); + if (functionList) { + this.doCallLaterList(functionList, thisList, argsList); } this.stage._updateTransform(); @@ -118,6 +118,7 @@ module egret{ } private reuseEvent:Event = new Event("") + /** * 广播EnterFrame事件。 */ @@ -128,57 +129,64 @@ module egret{ this.dispatchEvent(event); var list:Array = DisplayObject._enterFrameCallBackList.concat(); var length:number = list.length; - for(var i:number = 0;i=0;i--){ + for (i = list.length - 1; i >= 0; i--) { list[i]._checkFrame(); } } + /** * 广播Render事件。 */ - private broadcastRender():void{ + private broadcastRender():void { var event:Event = this.reuseEvent; event._type = Event.RENDER; var list:Array = DisplayObject._renderCallBackList.concat(); var length:number = list.length; - for(var i:number = 0;i,thisList:Array,argsList:Array):void{ + private doCallLaterList(funcList:Array, thisList:Array, argsList:Array):void { var length:number = funcList.length; - for(var i:number=0;i