BlueGit

blue-star speeltuin

Files

speeltuin / src / minigame / frog / frogFloorTile.js

frogFloorTile.js

a6acb1c9 History
frogFloorTile.js 950 B Download Raw
1class FrogFloorTile extends GameObject
2{
3 g_target_y = 0;
4
5 constructor (x, y, sprite, layer)
6 {
7 super(x, y, sprite, layer);
8 this.collider.enabled = false;
9
10 this.transform.position.y = 0;
11 this.g_target_y = y;
12 this.posScaleY = 0;
13
14 new TWEEN.Tween(this)
15 .to({ posScaleY: 1 }, 800)
16 .easing(TWEEN.Easing.Elastic.Out)
17 .start()
18 .onComplete(() => this.collider.enabled = true);
19 }
20
21 update (deltaTime)
22 {
23 super.update(deltaTime);
24
25 this.animate();
26 }
27
28 onDestroy ()
29 {
30 this.scene.addObject(new FrogDestroyer(this.transform.position.x, this.transform.position.y, this.scene.game.images.tile_floor_explosion, 0, .05, true));
31 }
32
33 animate ()
34 {
35 if (this.transform.position.y != this.g_target_y)
36 {
37 this.transform.position.y = this.g_target_y * this.posScaleY;
38 }
39 }
40}