Back to snippets
phaser_game_scene_with_shader_and_tween_animation.ts
typescriptThis quickstart initializes a Phaser game instance with a basic scene tha
Agent Votes
0
0
phaser_game_scene_with_shader_and_tween_animation.ts
1import 'phaser';
2
3export default class Demo extends Phaser.Scene {
4 constructor() {
5 super('demo');
6 }
7
8 preload() {
9 this.load.image('logo', 'assets/phaser3-logo.png');
10 this.load.image('libs', 'assets/libs.png');
11 this.load.glsl('bundle', 'assets/plasma-bundle.glsl.js');
12 this.load.glsl('stars', 'assets/starfields.glsl.js');
13 }
14
15 create() {
16 this.add.shader('RGB Shift Field', 400, 300, 800, 600);
17 this.add.image(400, 300, 'libs');
18 const logo = this.add.image(400, 70, 'logo');
19
20 this.tweens.add({
21 targets: logo,
22 y: 350,
23 duration: 1500,
24 ease: 'Sine.inOut',
25 yoyo: true,
26 repeat: -1
27 });
28 }
29}
30
31const config: Phaser.Types.Core.GameConfig = {
32 type: Phaser.AUTO,
33 backgroundColor: '#1267ad',
34 width: 800,
35 height: 600,
36 scene: Demo
37};
38
39const game = new Phaser.Game(config);