class BtnGames extends BaseMenu { buttons = []; buttonPadding = 10; state = 0; prevState = 1; constructor (sx, sy, ex, ey, sprite, layer, tOpen = 600, tClose = 800) { super(sx, sy, ex, ey, sprite, layer, tOpen, tClose); } addedToScene () { super.addedToScene(); this.initialiseChildren(); } initialiseChildren () { let target = this.getNextTargetPosition(); let buttonFrog = this.scene.addObject(new BaseMenuButton(this.originPosition.x, this.originPosition.y, target.x, target.y, this.scene.game.images.btnFrog, 3)); buttonFrog.onClick = function () { MinigameInitialiser.StartFrogGame(this.scene, new vector(this.targetPosition.x - this.transform.size.x / 2, this.targetPosition.y - this.transform.size.y / 2), this.transform.size); MainMenu.Instance.close(); }; buttonFrog.createActiveStateTween = function (time, onDone) { return BaseMenuButton.prototype.createActiveStateTween(time, onDone, this) .to({ x: [this.targetPosition.x], y: [this.originPosition.y, this.originPosition.y, this.originPosition.y, this.targetPosition.y] }, time) .easing(TWEEN.Easing.Back.Out); }; buttonFrog.createInactiveStateTween = function (time, onDone) { return BaseMenuButton.prototype.createInactiveStateTween(time, onDone, this) .to({ x: [this.targetPosition.x, this.targetPosition.x, this.targetPosition.x, this.targetPosition.x, this.originPosition.x], y: [this.originPosition.y] }, time) .easing(TWEEN.Easing.Quintic.Out); }; this.addChildButton("btnFrog", buttonFrog); } getNextTargetPosition () { if (this.children == 0) { return new vector(this.transform.position.x + this.transform.size.x * 2 + this.buttonPadding, this.transform.position.y + this.buttonPadding); } else { let previous = this.children[this.children.length - 1].button; current.endPos = new vector( previous.targetPosition.x, previous.targetPosition.y + previous.transform.size.y + this.buttonPadding); } } }