-
Notifications
You must be signed in to change notification settings - Fork 277
/
Copy pathanim2.js
109 lines (79 loc) · 3.16 KB
/
anim2.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
goog.provide('test.anim2');
goog.require('lime');
goog.require('lime.Director');
goog.require('lime.Layer');
goog.require('lime.Scene');
goog.require('lime.Sprite');
goog.require('lime.animation.Delay');
goog.require('lime.animation.FadeTo');
goog.require('lime.animation.MoveBy');
goog.require('lime.animation.MoveTo');
goog.require('lime.animation.RotateBy');
goog.require('lime.animation.ScaleBy');
goog.require('lime.animation.ScaleTo');
goog.require('lime.animation.Sequence');
goog.require('lime.animation.Spawn');
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 gamescene = new lime.Scene;
var flameLayer = new lime.Sprite().setAnchorPoint(0, 0);
flameLayer.setPosition(100, 0);
// canvas rendering for no reason
flameLayer.setRenderer(lime.Renderer.CANVAS);
gamescene.appendChild(flameLayer);
var scale = 1;
var flame = new lime.Sprite;
flameLayer.appendChild(flame);
flame.setFill(100, 0, 0);
flame.setRotation(10);
flame.setPosition(100, 100);
flame.setSize(200, 200);
// flame.setScale(flame.getScale().clone().scale(scale));
var move = new lime.animation.Sequence(
new lime.animation.Spawn(
(new lime.animation.ScaleBy(1.5)),
new lime.animation.FadeTo(0.5)
), new lime.animation.MoveBy(300, 300));
move.addTarget(flame);
flame = (new lime.Sprite)
.setFill('assets/nano.png')
.setPosition(300, 100)
.setScale(.3);
//var flame_x = flame.getPosition().x;
flameLayer.appendChild(flame);
move.addTarget(flame);
move.play();
flame = new lime.Sprite;
flameLayer.appendChild(flame);
flame.setFill('assets/nano.png');
flame.setPosition(new goog.math.Coordinate(50, 250));
flame.setOpacity(.6);
flame.setScale(flame.getScale().clone().scale(scale));
tex = new lime.Sprite;
tex.setFill('assets/nano.png');
tex.setScale(flame.getScale().clone().scale(scale));
/*
flame = new lime.Sprite;
flameLayer.appendChild(flame);
flame.setFill(tex);
flame.setPosition( new goog.math.Coordinate(300,250) );
flame.setScale(flame.getScale().clone().scale(scale));*/
// set active scene
test.director.replaceScene(gamescene);
/*goog.events.listen(document.body,'mousedown',function(e){
console.log(e.clientX+' '+e.clientY);
var p = test.director.getPosition();
console.log(p.x+' '+p.y);
var p2 = test.director.screenToLocal(new goog.math.Coordinate(e.clientX,e.clientY));
console.log('-->'+p2.x+' '+p2.y);
var p3 = flameLayer.screenToLocal(new goog.math.Coordinate(e.clientX,e.clientY));
console.log('>>>'+p3.x+' '+p3.y);
var p3 = flame.screenToLocal(new goog.math.Coordinate(e.clientX,e.clientY));
console.log('>>>'+p3.x+' '+p3.y);
},false);*/
};
goog.exportSymbol('test.start', test.start);