-
Notifications
You must be signed in to change notification settings - Fork 277
/
Copy pathanim4.js
88 lines (61 loc) · 2.16 KB
/
anim4.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
goog.provide('test.anim4');
goog.require('lime');
goog.require('lime.CoverNode');
goog.require('lime.Director');
goog.require('lime.Layer');
goog.require('lime.Scene');
goog.require('lime.Sprite');
goog.require('lime.Circle');
goog.require('lime.animation.MoveTo');
goog.require('lime.animation.Sequence');
goog.require('lime.animation.Loop');
goog.require('lime.animation.Delay');
test.WIDTH = 800;
test.HEIGHT = 400;
test.start = function() {
//director
test.director = new lime.Director(document.body,1024, 768);
test.director.makeMobileWebAppCapable();
var scene = new lime.Scene();
var circle = new lime.Circle()
.setSize(50, 50)
.setFill(255, 150, 0)
.setPosition(100, 100);
scene.appendChild(circle);
var moveRight = new lime.animation.MoveTo(874, 100)
.setSpeed(1)
.setEasing(lime.animation.Easing.LINEAR);
var moveLeft = new lime.animation.MoveTo(100, 100)
.setSpeed(1)
.setEasing(lime.animation.Easing.LINEAR);
goog.events.listen(moveRight,lime.animation.Event.STOP, function () {
setTimeout(function () {
circle.runAction(moveLeft);
}, 500);
});
goog.events.listen(moveLeft,lime.animation.Event.STOP, function () {
setTimeout(function () {
circle.runAction(moveRight);
}, 500);
});
circle.runAction(moveRight);
// better solution
var circle2 = new lime.Circle()
.setSize(50, 50)
.setFill(255, 150, 0)
.setPosition(100, 200);
scene.appendChild(circle2);
var moveRight2 = new lime.animation.MoveTo(874, 200)
.setDuration(774/100).setEasing(lime.animation.Easing.LINEAR);
var moveLeft2 = new lime.animation.MoveTo(100, 200)
.setDuration(774/100).setEasing(lime.animation.Easing.LINEAR);
circle2.runAction(new lime.animation.Loop(
new lime.animation.Sequence(
moveRight2, new lime.animation.Delay().setDuration(.5),
moveLeft2, new lime.animation.Delay().setDuration(.5)
)
));
// set current scene active
test.director.replaceScene(scene);
};
goog.exportSymbol('test.start', test.start);