|
|
|
@ -15,6 +15,10 @@ export class Game {
|
|
|
|
|
|
|
|
|
|
//初始化引擎和画布
|
|
|
|
|
public init(canvas: HTMLCanvasElement) { |
|
|
|
|
|
|
|
|
|
// FileTools.DefaultRetryStrategy = MyRetryStrategy.ExponentialBackoff(2, 1000);
|
|
|
|
|
// FileTools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff(2, 1000);
|
|
|
|
|
|
|
|
|
|
Game.instance = this; |
|
|
|
|
this.canvas = canvas; |
|
|
|
|
this.engine = new Engine(canvas, null, { stencil: true }); |
|
|
|
@ -66,3 +70,27 @@ export class Game {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
// * 重试策略
|
|
|
|
|
// */
|
|
|
|
|
// var MyRetryStrategy = /** @class */ (function () {
|
|
|
|
|
// function RetryStrategy() {
|
|
|
|
|
// }
|
|
|
|
|
// /**
|
|
|
|
|
// * Function used to defines an exponential back off strategy
|
|
|
|
|
// * @param maxRetries defines the maximum number of retries (3 by default)
|
|
|
|
|
// * @param baseInterval defines the interval between retries
|
|
|
|
|
// * @returns the strategy function to use
|
|
|
|
|
// */
|
|
|
|
|
// MyRetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
|
|
|
|
|
// if (maxRetries === void 0) { maxRetries = 3; }
|
|
|
|
|
// if (baseInterval === void 0) { baseInterval = 500; }
|
|
|
|
|
// return function (url, request, retryIndex) {
|
|
|
|
|
// if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
|
|
|
|
|
// return -1;
|
|
|
|
|
// }
|
|
|
|
|
// return Math.pow(2, retryIndex) * baseInterval;
|
|
|
|
|
// };
|
|
|
|
|
// };
|
|
|
|
|
// return MyRetryStrategy;
|
|
|
|
|
// }());
|
|
|
|
|