-
Notifications
You must be signed in to change notification settings - Fork 277
/
Copy pathanim1.js
72 lines (50 loc) · 2.02 KB
/
anim1.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
goog.provide('test.anim1');
goog.require('lime');
goog.require('lime.Button');
goog.require('lime.Circle');
goog.require('lime.CoverNode');
goog.require('lime.Director');
goog.require('lime.Label');
goog.require('lime.Layer');
goog.require('lime.Scene');
goog.require('lime.Sprite');
goog.require('lime.animation.Loop');
goog.require('lime.animation.MoveBy');
goog.require('lime.animation.RotateBy');
goog.require('lime.animation.ScaleBy');
goog.require('lime.animation.Sequence');
goog.require('lime.animation.Spawn');
goog.require('lime.animation.ColorTo');
test.WIDTH = 600;
test.HEIGHT = 400;
test.start = function() {
//director
test.director = new lime.Director(document.body, test.WIDTH, test.HEIGHT);
test.director.makeMobileWebAppCapable();
var menuscene = new lime.Scene;
var layer = (new lime.Layer).setPosition(100, 100);
menuscene.appendChild(layer);
var sprite = new lime.Sprite().setFill(100,0,0).setSize(50, 50).setRenderer(lime.Renderer.CANVAS);
layer.appendChild(sprite);
var anim = new lime.animation.Sequence(new lime.animation.Spawn(
new lime.animation.MoveBy(200, 0).setDuration(1.5),
new lime.animation.ScaleBy(2),
new lime.animation.ColorTo(0,200,0)
), new lime.animation.Spawn(
new lime.animation.MoveBy(-200, 0).setDuration(1.5),
new lime.animation.ScaleBy(.5),
new lime.animation.ColorTo(200,0,0)
));
sprite.runAction(new lime.animation.Loop(anim).setLimit(5));
var sprite = new lime.Sprite().setFill('#0c0').setSize(50, 50).setPosition(0, 100).setRenderer(lime.Renderer.CANVAS);
layer.appendChild(sprite);
var anim = new lime.animation.Spawn(
new lime.animation.RotateBy(-90).setDuration(3),
new lime.animation.MoveBy(300, 0).setDuration(3)
);
var a2 = new lime.animation.Sequence(anim, anim.reverse());
sprite.runAction(new lime.animation.Loop(a2).setLimit(5));
// set active scene
test.director.replaceScene(menuscene);
};
goog.exportSymbol('test.start', test.start);