forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombined tweens.js
52 lines (32 loc) · 1.1 KB
/
combined tweens.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', {preload:preload,create: create });
function preload() {
game.load.spritesheet('pig', 'assets/sprites/invaderpig.png', 124, 104);
game.load.image('starfield', 'assets/misc/starfield.jpg');
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
}
var mushroom;
var pig;
var pigArrives;
var s;
function create() {
game.add.tileSprite(0, 0, 800, 600, 'starfield');
pig = game.add.sprite(-50, 200, 'pig', 1);
pig.scale.setTo(0.5, 0.5);
mushroom = game.add.sprite(380, 200, 'mushroom');
mushroom.anchor.setTo(0.5, 0.5);
pigArrives = game.add.tween(pig);
pigArrives.to({x:150}, 1000, Phaser.Easing.Bounce.Out);
pigArrives.onComplete.add(firstTween, this);
pigArrives.start();
}
function firstTween() {
s = game.add.tween(mushroom.scale);
s.to({x: 2, y:2}, 1000, Phaser.Easing.Linear.None);
s.onComplete.addOnce(theEnd, this);
s.start();
}
function theEnd() {
e = game.add.tween(pig);
e.to({ x: -150 }, 1000, Phaser.Easing.Bounce.Out);
e.start();
}