新增 CoroutineManager 协同程序
This commit is contained in:
@@ -58,8 +58,8 @@ module es {
|
||||
this._scrollX += this.scrollSpeedX * Time.deltaTime;
|
||||
this._scrollY += this.scroolSpeedY * Time.deltaTime;
|
||||
|
||||
this._sourceRect.x = this._scrollX;
|
||||
this._sourceRect.y = this._scrollY;
|
||||
this._sourceRect.x = Math.floor(this._scrollX);
|
||||
this._sourceRect.y = Math.floor(this._scrollY);
|
||||
this._sourceRect.width = this._scrollWidth + Math.abs(this._scrollX);
|
||||
this._sourceRect.height = this._scrollHeight + Math.abs(this._scrollY);
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ module es {
|
||||
|
||||
// 重新计算我们的inverseTextureScale和源矩形大小
|
||||
this._inverseTexScale = new Vector2(1 / this._textureScale.x, 1 / this._textureScale.y);
|
||||
this._sourceRect.width = this._sprite.sourceRect.width * this._inverseTexScale.x;
|
||||
this._sourceRect.height = this._sprite.sourceRect.height * this._inverseTexScale.y;
|
||||
this._sourceRect.width = Math.floor(this._sprite.sourceRect.width * this._inverseTexScale.x);
|
||||
this._sourceRect.height = Math.floor(this._sprite.sourceRect.height * this._inverseTexScale.y);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -29,6 +29,7 @@ module es {
|
||||
* 全局访问系统
|
||||
*/
|
||||
public _globalManagers: GlobalManager[] = [];
|
||||
public _coroutineManager: CoroutineManager = new CoroutineManager();
|
||||
public _timerManager: TimerManager = new TimerManager();
|
||||
|
||||
constructor() {
|
||||
@@ -40,6 +41,7 @@ module es {
|
||||
|
||||
this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
|
||||
|
||||
Core.registerGlobalManager(this._coroutineManager);
|
||||
Core.registerGlobalManager(this._timerManager);
|
||||
}
|
||||
|
||||
@@ -126,6 +128,15 @@ module es {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始了一个协同程序。协程可以使用number延迟几秒,也可以使其他对startCoroutine的调用延迟几秒。
|
||||
* 返回null将使协程在下一帧中被执行。
|
||||
* @param enumerator
|
||||
*/
|
||||
public static startCoroutine(enumerator: IEnumerator){
|
||||
return this._instance._coroutineManager.startCoroutine(enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调度一个一次性或重复的计时器,该计时器将调用已传递的动作
|
||||
* @param timeInSeconds
|
||||
|
||||
@@ -33,7 +33,7 @@ module es {
|
||||
*/
|
||||
public static checkEvery(interval: number) {
|
||||
// 我们减去了delta,因为timeSinceSceneLoad已经包含了这个update ticks delta
|
||||
return (this._timeSinceSceneLoad / interval) > ((this._timeSinceSceneLoad - this.deltaTime) / interval);
|
||||
return Math.floor(this._timeSinceSceneLoad / interval) > Math.floor((this._timeSinceSceneLoad - this.deltaTime) / interval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user