| 1 | class BtnGames extends BaseMenu |
| 2 | { |
| 3 | buttons = []; |
| 4 | buttonPadding = 10; |
| 5 | state = 0; |
| 6 | prevState = 1; |
| 7 | |
| 8 | constructor (sx, sy, ex, ey, sprite, layer, tOpen = 600, tClose = 800) |
| 9 | { |
| 10 | super(sx, sy, ex, ey, sprite, layer, tOpen, tClose); |
| 11 | } |
| 12 | |
| 13 | addedToScene () |
| 14 | { |
| 15 | super.addedToScene(); |
| 16 | |
| 17 | this.initialiseChildren(); |
| 18 | } |
| 19 | |
| 20 | initialiseChildren () |
| 21 | { |
| 22 | let target = this.getNextTargetPosition(); |
| 23 | let buttonFrog = this.scene.addObject(new BaseMenuButton(this.originPosition.x, this.originPosition.y, target.x, target.y, this.scene.game.images.btnFrog, 3)); |
| 24 | buttonFrog.onClick = function () |
| 25 | { |
| 26 | 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); |
| 27 | MainMenu.Instance.close(); |
| 28 | }; |
| 29 | |
| 30 | buttonFrog.createActiveStateTween = function (time, onDone) |
| 31 | { |
| 32 | return BaseMenuButton.prototype.createActiveStateTween(time, onDone, this) |
| 33 | .to({ x: [this.targetPosition.x], y: [this.originPosition.y, this.originPosition.y, this.originPosition.y, this.targetPosition.y] }, time) |
| 34 | .easing(TWEEN.Easing.Back.Out); |
| 35 | }; |
| 36 | |
| 37 | buttonFrog.createInactiveStateTween = function (time, onDone) |
| 38 | { |
| 39 | return BaseMenuButton.prototype.createInactiveStateTween(time, onDone, this) |
| 40 | .to({ x: [this.targetPosition.x, this.targetPosition.x, this.targetPosition.x, this.targetPosition.x, this.originPosition.x], y: [this.originPosition.y] }, time) |
| 41 | .easing(TWEEN.Easing.Quintic.Out); |
| 42 | }; |
| 43 | |
| 44 | this.addChildButton("btnFrog", buttonFrog); |
| 45 | } |
| 46 | |
| 47 | getNextTargetPosition () |
| 48 | { |
| 49 | if (this.children == 0) |
| 50 | { |
| 51 | return new vector(this.transform.position.x + this.transform.size.x * 2 + this.buttonPadding, this.transform.position.y + this.buttonPadding); |
| 52 | } |
| 53 | else |
| 54 | { |
| 55 | let previous = this.children[this.children.length - 1].button; |
| 56 | |
| 57 | current.endPos = new vector( |
| 58 | previous.targetPosition.x, |
| 59 | previous.targetPosition.y + previous.transform.size.y + this.buttonPadding); |
| 60 | } |
| 61 | } |
| 62 | } |