Mercurial > MadButterfly
annotate nodejs/examples/testsvg/testsvg.js @ 1160:1a699dc00fa3
Fix the issue of not removing node in old scene when switching scenes.
- When a timeline is playing and crossing two scenes (tween block),
nodes, for the old scene, in duplicate group must be removed. But,
it is not.
- It is fixed by checking if nodes, in the duplicate group, are also
in the key frame next to the new scene. All nodes that is not in
next key frame are remove.
author | Thinker K.F. Li <thinker@codemud.net> |
---|---|
date | Tue, 28 Dec 2010 13:35:34 +0800 |
parents | a74b4d986a91 |
children |
rev | line source |
---|---|
822
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
775
diff
changeset
|
1 // -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- |
586e50f82c1f
Unify coding style tag for emacs and vim.
Shih-Yuan Lee (FourDollars) <fourdollars@gmail.com>
parents:
775
diff
changeset
|
2 // vim: sw=4:ts=8:sts=4 |
939
a74b4d986a91
Move examples for nodejs into nodejs/examples/ sub-directories.
Thinker K.F. Li <thinker@codemud.net>
parents:
937
diff
changeset
|
3 var svg = require("svg"); |
a74b4d986a91
Move examples for nodejs into nodejs/examples/ sub-directories.
Thinker K.F. Li <thinker@codemud.net>
parents:
937
diff
changeset
|
4 var mbapp = require("mbapp"); |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
5 var sys=require("sys"); |
939
a74b4d986a91
Move examples for nodejs into nodejs/examples/ sub-directories.
Thinker K.F. Li <thinker@codemud.net>
parents:
937
diff
changeset
|
6 var animate=require("animate"); |
732
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
7 var fs = require("fs"); |
714 | 8 |
716 | 9 app = new mbapp.app(); |
10 app.loadSVG("test.svg"); | |
723
8af3b87b502e
Correct syntax if a statement
Thinker K.F. Li <thinker@branda.to>
parents:
722
diff
changeset
|
11 lightbar = app.get("item_lightbar"); |
8af3b87b502e
Correct syntax if a statement
Thinker K.F. Li <thinker@branda.to>
parents:
722
diff
changeset
|
12 item=1; |
937
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
13 var target = app.get("item" + item); |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
14 lightbar.center.move_pnt(target.center); |
722
f95d58a8edd1
Add javascript-based animation test program. We should make it as module in the future.
wycc
parents:
721
diff
changeset
|
15 |
732
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
16 app.files=fs.readdirSync("/tmp/"); |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
17 for(i=1;i<10;i++) { |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
18 var o = app.get("item"+i+"text"); |
937
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
19 o.set_text(app.files[i]); |
732
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
20 } |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
21 |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
22 |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
23 |
6879aa403306
Add set_text to the coordinate of the coord_t of the text.
wycc
parents:
730
diff
changeset
|
24 |
730 | 25 app.addKeyListener(mbapp.KEY_UP, function() { |
937
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
26 item = item - 1; |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
27 if (item == 0) |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
28 item = 1; |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
29 else { |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
30 var target = app.get("item"+item); |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
31 var shx = target.center.x - lightbar.center.x; |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
32 var shy = target.center.y - lightbar.center.y; |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
33 var action = new animate.shift(app, lightbar, shx, shy); |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
34 var an = new animate.linear(action, 0, 0.3); |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
35 an.start(); |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
36 } |
730 | 37 }); |
38 | |
39 app.addKeyListener(mbapp.KEY_DOWN, function() { | |
937
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
40 item = item + 1; |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
41 if (item == 10) { |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
42 item = 9; |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
43 } else { |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
44 var target = app.get("item"+item); |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
45 var shx = target.center.x - lightbar.center.x; |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
46 var shy = target.center.y - lightbar.center.y; |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
47 var action = new animate.shift(app, lightbar, shx, shy); |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
48 var an = new animate.linear(action, 0, 0.3); |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
49 an.start(); |
191d3a5f74c8
Migrate testsvg.js to new interface of shift action.
Thinker K.F. Li <thinker@codemud.net>
parents:
822
diff
changeset
|
50 } |
721
01d02382dea7
Refactory the mbapp and testsvg to use keyboard events
wycc
parents:
716
diff
changeset
|
51 }); |
730 | 52 |
716 | 53 app.loop(); |