export default class GameStage extends egret.DisplayObjectContainer {
    public shake() {
        return new Promise((resolve) => {
            let back = false;
            let onUpdate = () => {
                let gameStage:GameStage = this;
                if (!back) {
                    gameStage.y += 1;
                    if (gameStage.y >= 9) {
                        back = true;
                    }
                } else {
                    gameStage.y -= 1;
                    if (gameStage.y <= 0) {
                        gameStage.y = 0;
                        this.removeEventListener(egret.Event.ENTER_FRAME, onUpdate, this);
                        resolve();
                    }
                }
            };

            this.addEventListener(egret.Event.ENTER_FRAME, onUpdate, this);
        });
    }
}