-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstop-tweener.html
41 lines (34 loc) · 961 Bytes
/
stop-tweener.html
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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>cancelTweener example</title>
<script src="../src/libs/crafty-0.6.2.min.js"></script>
<script src="../src/components/Tweener.js"></script>
<script>
window.onload = function() {
var hasTweens = true;
Crafty.init(640, 480);
Crafty.canvas.init();
Crafty.background("#88FF99");
Crafty.e("2D, Canvas, Color, Tweener, Mouse")
.attr({ x: 150, y: 40, w: 40, h: 40 })
.color("#339988")
.origin(20, 20)
.addTween({ y: 400, rotation: 3600}, 'easeOutBounce', 1000)
.bind("Click", function() {
if (hasTweens) {
hasTweens = false;
this.cancelTweener();
} else {
hasTweens = true;
this.addTween({ y: 400, rotation: 3600}, 'easeOutBounce', 1000);
}
});
};
</script>
</head>
<body>
<p>cancelTweener() demonstration. Click the cube before the tween stops to completely stop all it's tweens.</p>
</body>
</html>