Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
c7d2872d
Commit
c7d2872d
authored
Aug 27, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds new enemies and coin display to demo game
parent
eb84a0ca
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
252 additions
and
77 deletions
+252
-77
game_ui.json
examples/game/assets/game_ui.json
+23
-14
game_ui.png
examples/game/assets/game_ui.png
+0
-0
sprites.json
examples/game/assets/sprites.json
+49
-22
sprites.png
examples/game/assets/sprites.png
+0
-0
custom_actions.dart
examples/game/lib/custom_actions.dart
+19
-0
explosions.dart
examples/game/lib/explosions.dart
+11
-1
game_demo.dart
examples/game/lib/game_demo.dart
+2
-0
game_demo_node.dart
examples/game/lib/game_demo_node.dart
+3
-3
game_object_factory.dart
examples/game/lib/game_object_factory.dart
+14
-5
game_objects.dart
examples/game/lib/game_objects.dart
+94
-13
player_state.dart
examples/game/lib/player_state.dart
+37
-19
No files found.
examples/game/assets/game_ui.json
View file @
c7d2872d
...
@@ -36,6 +36,15 @@
...
@@ -36,6 +36,15 @@
"sourceSize"
:
{
"w"
:
472
,
"h"
:
484
},
"sourceSize"
:
{
"w"
:
472
,
"h"
:
484
},
"pivot"
:
{
"x"
:
0.5
,
"y"
:
0.5
}
"pivot"
:
{
"x"
:
0.5
,
"y"
:
0.5
}
},
},
{
"filename"
:
"coinboard.png"
,
"frame"
:
{
"x"
:
366
,
"y"
:
1056
,
"w"
:
261
,
"h"
:
100
},
"rotated"
:
true
,
"trimmed"
:
false
,
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
261
,
"h"
:
100
},
"sourceSize"
:
{
"w"
:
261
,
"h"
:
100
},
"pivot"
:
{
"x"
:
0.5
,
"y"
:
0.5
}
},
{
{
"filename"
:
"number_0.png"
,
"filename"
:
"number_0.png"
,
"frame"
:
{
"x"
:
416
,
"y"
:
954
,
"w"
:
38
,
"h"
:
63
},
"frame"
:
{
"x"
:
416
,
"y"
:
954
,
"w"
:
38
,
"h"
:
63
},
...
@@ -47,7 +56,7 @@
...
@@ -47,7 +56,7 @@
},
},
{
{
"filename"
:
"number_1.png"
,
"filename"
:
"number_1.png"
,
"frame"
:
{
"x"
:
324
,
"y"
:
1221
,
"w"
:
16
,
"h"
:
57
},
"frame"
:
{
"x"
:
299
,
"y"
:
1286
,
"w"
:
16
,
"h"
:
57
},
"rotated"
:
true
,
"rotated"
:
true
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
45
,
"y"
:
25
,
"w"
:
16
,
"h"
:
57
},
"spriteSourceSize"
:
{
"x"
:
45
,
"y"
:
25
,
"w"
:
16
,
"h"
:
57
},
...
@@ -56,7 +65,7 @@
...
@@ -56,7 +65,7 @@
},
},
{
{
"filename"
:
"number_2.png"
,
"filename"
:
"number_2.png"
,
"frame"
:
{
"x"
:
3
66
,
"y"
:
10
56
,
"w"
:
38
,
"h"
:
63
},
"frame"
:
{
"x"
:
3
24
,
"y"
:
11
56
,
"w"
:
38
,
"h"
:
63
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
23
,
"y"
:
22
,
"w"
:
38
,
"h"
:
63
},
"spriteSourceSize"
:
{
"x"
:
23
,
"y"
:
22
,
"w"
:
38
,
"h"
:
63
},
...
@@ -65,8 +74,8 @@
...
@@ -65,8 +74,8 @@
},
},
{
{
"filename"
:
"number_3.png"
,
"filename"
:
"number_3.png"
,
"frame"
:
{
"x"
:
364
,
"y"
:
1156
,
"w"
:
35
,
"h"
:
63
},
"frame"
:
{
"x"
:
197
,
"y"
:
1230
,
"w"
:
35
,
"h"
:
63
},
"rotated"
:
fals
e
,
"rotated"
:
tru
e
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
26
,
"y"
:
22
,
"w"
:
35
,
"h"
:
63
},
"spriteSourceSize"
:
{
"x"
:
26
,
"y"
:
22
,
"w"
:
35
,
"h"
:
63
},
"sourceSize"
:
{
"w"
:
84
,
"h"
:
107
},
"sourceSize"
:
{
"w"
:
84
,
"h"
:
107
},
...
@@ -74,8 +83,8 @@
...
@@ -74,8 +83,8 @@
},
},
{
{
"filename"
:
"number_4.png"
,
"filename"
:
"number_4.png"
,
"frame"
:
{
"x"
:
416
,
"y"
:
1019
,
"w"
:
38
,
"h"
:
57
},
"frame"
:
{
"x"
:
197
,
"y"
:
1267
,
"w"
:
38
,
"h"
:
57
},
"rotated"
:
fals
e
,
"rotated"
:
tru
e
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
23
,
"y"
:
25
,
"w"
:
38
,
"h"
:
57
},
"spriteSourceSize"
:
{
"x"
:
23
,
"y"
:
25
,
"w"
:
38
,
"h"
:
57
},
"sourceSize"
:
{
"w"
:
84
,
"h"
:
107
},
"sourceSize"
:
{
"w"
:
84
,
"h"
:
107
},
...
@@ -83,7 +92,7 @@
...
@@ -83,7 +92,7 @@
},
},
{
{
"filename"
:
"number_5.png"
,
"filename"
:
"number_5.png"
,
"frame"
:
{
"x"
:
324
,
"y"
:
1
156
,
"w"
:
38
,
"h"
:
63
},
"frame"
:
{
"x"
:
324
,
"y"
:
1
221
,
"w"
:
38
,
"h"
:
63
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
23
,
"y"
:
22
,
"w"
:
38
,
"h"
:
63
},
"spriteSourceSize"
:
{
"x"
:
23
,
"y"
:
22
,
"w"
:
38
,
"h"
:
63
},
...
@@ -92,7 +101,7 @@
...
@@ -92,7 +101,7 @@
},
},
{
{
"filename"
:
"number_6.png"
,
"filename"
:
"number_6.png"
,
"frame"
:
{
"x"
:
406
,
"y"
:
1078
,
"w"
:
38
,
"h"
:
63
},
"frame"
:
{
"x"
:
2
,
"y"
:
1230
,
"w"
:
38
,
"h"
:
63
},
"rotated"
:
true
,
"rotated"
:
true
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
23
,
"y"
:
22
,
"w"
:
38
,
"h"
:
63
},
"spriteSourceSize"
:
{
"x"
:
23
,
"y"
:
22
,
"w"
:
38
,
"h"
:
63
},
...
@@ -101,8 +110,8 @@
...
@@ -101,8 +110,8 @@
},
},
{
{
"filename"
:
"number_7.png"
,
"filename"
:
"number_7.png"
,
"frame"
:
{
"x"
:
401
,
"y"
:
1198
,
"w"
:
35
,
"h"
:
60
},
"frame"
:
{
"x"
:
262
,
"y"
:
1230
,
"w"
:
35
,
"h"
:
60
},
"rotated"
:
tru
e
,
"rotated"
:
fals
e
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
26
,
"y"
:
22
,
"w"
:
35
,
"h"
:
60
},
"spriteSourceSize"
:
{
"x"
:
26
,
"y"
:
22
,
"w"
:
35
,
"h"
:
60
},
"sourceSize"
:
{
"w"
:
84
,
"h"
:
107
},
"sourceSize"
:
{
"w"
:
84
,
"h"
:
107
},
...
@@ -110,7 +119,7 @@
...
@@ -110,7 +119,7 @@
},
},
{
{
"filename"
:
"number_8.png"
,
"filename"
:
"number_8.png"
,
"frame"
:
{
"x"
:
406
,
"y"
:
1118
,
"w"
:
38
,
"h"
:
63
},
"frame"
:
{
"x"
:
67
,
"y"
:
1230
,
"w"
:
38
,
"h"
:
63
},
"rotated"
:
true
,
"rotated"
:
true
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
23
,
"y"
:
22
,
"w"
:
38
,
"h"
:
63
},
"spriteSourceSize"
:
{
"x"
:
23
,
"y"
:
22
,
"w"
:
38
,
"h"
:
63
},
...
@@ -119,7 +128,7 @@
...
@@ -119,7 +128,7 @@
},
},
{
{
"filename"
:
"number_9.png"
,
"filename"
:
"number_9.png"
,
"frame"
:
{
"x"
:
401
,
"y"
:
1158
,
"w"
:
38
,
"h"
:
63
},
"frame"
:
{
"x"
:
132
,
"y"
:
1230
,
"w"
:
38
,
"h"
:
63
},
"rotated"
:
true
,
"rotated"
:
true
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
23
,
"y"
:
22
,
"w"
:
38
,
"h"
:
63
},
"spriteSourceSize"
:
{
"x"
:
23
,
"y"
:
22
,
"w"
:
38
,
"h"
:
63
},
...
@@ -140,8 +149,8 @@
...
@@ -140,8 +149,8 @@
"version"
:
"1.0"
,
"version"
:
"1.0"
,
"image"
:
"game_ui.png"
,
"image"
:
"game_ui.png"
,
"format"
:
"RGBA8888"
,
"format"
:
"RGBA8888"
,
"size"
:
{
"w"
:
472
,
"h"
:
1
23
9
},
"size"
:
{
"w"
:
472
,
"h"
:
1
31
9
},
"scale"
:
"1"
,
"scale"
:
"1"
,
"smartupdate"
:
"$TexturePacker:SmartUpdate:
02d6676bdde949110cbdc9a2c385b33a:6b0974f94eba9593dd9636cc730412b8
:10ac111e32c27e51f4e8444dbb39eff6$"
"smartupdate"
:
"$TexturePacker:SmartUpdate:
2fc7dfe766eba152274e2661737d6b51:b44b32d1e0a4146b3591d51b12f2d7ae
:10ac111e32c27e51f4e8444dbb39eff6$"
}
}
}
}
examples/game/assets/game_ui.png
View file @
c7d2872d
This diff was suppressed by a .gitattributes entry.
examples/game/assets/sprites.json
View file @
c7d2872d
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
},
},
{
{
"filename"
:
"asteroid_big_0.png"
,
"filename"
:
"asteroid_big_0.png"
,
"frame"
:
{
"x"
:
2
60
,
"y"
:
193
,
"w"
:
200
,
"h"
:
167
},
"frame"
:
{
"x"
:
2
,
"y"
:
450
,
"w"
:
200
,
"h"
:
167
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
21
,
"w"
:
200
,
"h"
:
167
},
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
21
,
"w"
:
200
,
"h"
:
167
},
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
},
},
{
{
"filename"
:
"asteroid_big_1.nrm.png"
,
"filename"
:
"asteroid_big_1.nrm.png"
,
"frame"
:
{
"x"
:
451
,
"y"
:
2
,
"w"
:
204
,
"h"
:
166
},
"frame"
:
{
"x"
:
2
,
"y"
:
619
,
"w"
:
204
,
"h"
:
166
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
false
,
"trimmed"
:
false
,
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
204
,
"h"
:
166
},
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
204
,
"h"
:
166
},
...
@@ -29,7 +29,7 @@
...
@@ -29,7 +29,7 @@
},
},
{
{
"filename"
:
"asteroid_big_1.png"
,
"filename"
:
"asteroid_big_1.png"
,
"frame"
:
{
"x"
:
657
,
"y"
:
2
,
"w"
:
204
,
"h"
:
166
},
"frame"
:
{
"x"
:
2
,
"y"
:
787
,
"w"
:
204
,
"h"
:
166
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
false
,
"trimmed"
:
false
,
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
204
,
"h"
:
166
},
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
204
,
"h"
:
166
},
...
@@ -38,7 +38,7 @@
...
@@ -38,7 +38,7 @@
},
},
{
{
"filename"
:
"asteroid_big_2.nrm.png"
,
"filename"
:
"asteroid_big_2.nrm.png"
,
"frame"
:
{
"x"
:
462
,
"y"
:
170
,
"w"
:
194
,
"h"
:
165
},
"frame"
:
{
"x"
:
204
,
"y"
:
335
,
"w"
:
194
,
"h"
:
165
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
false
,
"trimmed"
:
false
,
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
194
,
"h"
:
165
},
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
194
,
"h"
:
165
},
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
},
},
{
{
"filename"
:
"asteroid_big_2.png"
,
"filename"
:
"asteroid_big_2.png"
,
"frame"
:
{
"x"
:
658
,
"y"
:
170
,
"w"
:
194
,
"h"
:
165
},
"frame"
:
{
"x"
:
208
,
"y"
:
502
,
"w"
:
194
,
"h"
:
165
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
2
,
"w"
:
194
,
"h"
:
165
},
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
2
,
"w"
:
194
,
"h"
:
165
},
...
@@ -56,7 +56,7 @@
...
@@ -56,7 +56,7 @@
},
},
{
{
"filename"
:
"asteroid_small_0.nrm.png"
,
"filename"
:
"asteroid_small_0.nrm.png"
,
"frame"
:
{
"x"
:
204
,
"y"
:
362
,
"w"
:
102
,
"h"
:
84
},
"frame"
:
{
"x"
:
347
,
"y"
:
843
,
"w"
:
102
,
"h"
:
84
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
false
,
"trimmed"
:
false
,
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
102
,
"h"
:
84
},
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
102
,
"h"
:
84
},
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
},
},
{
{
"filename"
:
"asteroid_small_0.png"
,
"filename"
:
"asteroid_small_0.png"
,
"frame"
:
{
"x"
:
3
08
,
"y"
:
362
,
"w"
:
102
,
"h"
:
84
},
"frame"
:
{
"x"
:
3
47
,
"y"
:
929
,
"w"
:
102
,
"h"
:
84
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
false
,
"trimmed"
:
false
,
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
102
,
"h"
:
84
},
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
102
,
"h"
:
84
},
...
@@ -74,7 +74,7 @@
...
@@ -74,7 +74,7 @@
},
},
{
{
"filename"
:
"asteroid_small_1.nrm.png"
,
"filename"
:
"asteroid_small_1.nrm.png"
,
"frame"
:
{
"x"
:
854
,
"y"
:
21
3
,
"w"
:
96
,
"h"
:
102
},
"frame"
:
{
"x"
:
404
,
"y"
:
46
3
,
"w"
:
96
,
"h"
:
102
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
false
,
"trimmed"
:
false
,
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
96
,
"h"
:
102
},
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
96
,
"h"
:
102
},
...
@@ -83,7 +83,7 @@
...
@@ -83,7 +83,7 @@
},
},
{
{
"filename"
:
"asteroid_small_1.png"
,
"filename"
:
"asteroid_small_1.png"
,
"frame"
:
{
"x"
:
854
,
"y"
:
31
7
,
"w"
:
96
,
"h"
:
102
},
"frame"
:
{
"x"
:
404
,
"y"
:
56
7
,
"w"
:
96
,
"h"
:
102
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
96
,
"h"
:
102
},
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
96
,
"h"
:
102
},
...
@@ -92,7 +92,7 @@
...
@@ -92,7 +92,7 @@
},
},
{
{
"filename"
:
"asteroid_small_2.nrm.png"
,
"filename"
:
"asteroid_small_2.nrm.png"
,
"frame"
:
{
"x"
:
740
,
"y"
:
337
,
"w"
:
109
,
"h"
:
84
},
"frame"
:
{
"x"
:
347
,
"y"
:
671
,
"w"
:
109
,
"h"
:
84
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
false
,
"trimmed"
:
false
,
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
109
,
"h"
:
84
},
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
109
,
"h"
:
84
},
...
@@ -101,16 +101,43 @@
...
@@ -101,16 +101,43 @@
},
},
{
{
"filename"
:
"asteroid_small_2.png"
,
"filename"
:
"asteroid_small_2.png"
,
"frame"
:
{
"x"
:
740
,
"y"
:
423
,
"w"
:
109
,
"h"
:
84
},
"frame"
:
{
"x"
:
347
,
"y"
:
757
,
"w"
:
109
,
"h"
:
84
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
false
,
"trimmed"
:
false
,
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
109
,
"h"
:
84
},
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
109
,
"h"
:
84
},
"sourceSize"
:
{
"w"
:
109
,
"h"
:
84
},
"sourceSize"
:
{
"w"
:
109
,
"h"
:
84
},
"pivot"
:
{
"x"
:
0.5
,
"y"
:
0.5
}
"pivot"
:
{
"x"
:
0.5
,
"y"
:
0.5
}
},
},
{
"filename"
:
"coin.png"
,
"frame"
:
{
"x"
:
429
,
"y"
:
270
,
"w"
:
42
,
"h"
:
47
},
"rotated"
:
false
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
6
,
"y"
:
4
,
"w"
:
42
,
"h"
:
47
},
"sourceSize"
:
{
"w"
:
54
,
"h"
:
56
},
"pivot"
:
{
"x"
:
0.5
,
"y"
:
0.5
}
},
{
"filename"
:
"enemy_destroyer_1.png"
,
"frame"
:
{
"x"
:
260
,
"y"
:
193
,
"w"
:
167
,
"h"
:
140
},
"rotated"
:
false
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
10
,
"y"
:
31
,
"w"
:
167
,
"h"
:
140
},
"sourceSize"
:
{
"w"
:
188
,
"h"
:
188
},
"pivot"
:
{
"x"
:
0.5
,
"y"
:
0.5
}
},
{
"filename"
:
"enemy_scout_0.png"
,
"frame"
:
{
"x"
:
400
,
"y"
:
335
,
"w"
:
107
,
"h"
:
126
},
"rotated"
:
false
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
11
,
"y"
:
1
,
"w"
:
107
,
"h"
:
126
},
"sourceSize"
:
{
"w"
:
129
,
"h"
:
129
},
"pivot"
:
{
"x"
:
0.5
,
"y"
:
0.5
}
},
{
{
"filename"
:
"explosion_flare.png"
,
"filename"
:
"explosion_flare.png"
,
"frame"
:
{
"x"
:
863
,
"y"
:
2
,
"w"
:
56
,
"h"
:
209
},
"frame"
:
{
"x"
:
451
,
"y"
:
2
,
"w"
:
56
,
"h"
:
209
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
4
,
"y"
:
0
,
"w"
:
56
,
"h"
:
209
},
"spriteSourceSize"
:
{
"x"
:
4
,
"y"
:
0
,
"w"
:
56
,
"h"
:
209
},
...
@@ -119,7 +146,7 @@
...
@@ -119,7 +146,7 @@
},
},
{
{
"filename"
:
"explosion_particle.png"
,
"filename"
:
"explosion_particle.png"
,
"frame"
:
{
"x"
:
2
,
"y"
:
45
0
,
"w"
:
36
,
"h"
:
60
},
"frame"
:
{
"x"
:
2
04
,
"y"
:
26
0
,
"w"
:
36
,
"h"
:
60
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
14
,
"y"
:
1
,
"w"
:
36
,
"h"
:
60
},
"spriteSourceSize"
:
{
"x"
:
14
,
"y"
:
1
,
"w"
:
36
,
"h"
:
60
},
...
@@ -137,7 +164,7 @@
...
@@ -137,7 +164,7 @@
},
},
{
{
"filename"
:
"fire_particle.png"
,
"filename"
:
"fire_particle.png"
,
"frame"
:
{
"x"
:
4
0
,
"y"
:
450
,
"w"
:
55
,
"h"
:
55
},
"frame"
:
{
"x"
:
4
29
,
"y"
:
213
,
"w"
:
55
,
"h"
:
55
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
4
,
"y"
:
4
,
"w"
:
55
,
"h"
:
55
},
"spriteSourceSize"
:
{
"x"
:
4
,
"y"
:
4
,
"w"
:
55
,
"h"
:
55
},
...
@@ -146,7 +173,7 @@
...
@@ -146,7 +173,7 @@
},
},
{
{
"filename"
:
"laser.png"
,
"filename"
:
"laser.png"
,
"frame"
:
{
"x"
:
204
,
"y"
:
260
,
"w"
:
37
,
"h"
:
76
},
"frame"
:
{
"x"
:
458
,
"y"
:
671
,
"w"
:
37
,
"h"
:
76
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
false
,
"trimmed"
:
false
,
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
37
,
"h"
:
76
},
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
37
,
"h"
:
76
},
...
@@ -164,7 +191,7 @@
...
@@ -164,7 +191,7 @@
},
},
{
{
"filename"
:
"ship.nrm.png"
,
"filename"
:
"ship.nrm.png"
,
"frame"
:
{
"x"
:
462
,
"y"
:
337
,
"w"
:
137
,
"h"
:
167
},
"frame"
:
{
"x"
:
208
,
"y"
:
669
,
"w"
:
137
,
"h"
:
167
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
false
,
"trimmed"
:
false
,
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
137
,
"h"
:
167
},
"spriteSourceSize"
:
{
"x"
:
0
,
"y"
:
0
,
"w"
:
137
,
"h"
:
167
},
...
@@ -173,7 +200,7 @@
...
@@ -173,7 +200,7 @@
},
},
{
{
"filename"
:
"ship.png"
,
"filename"
:
"ship.png"
,
"frame"
:
{
"x"
:
601
,
"y"
:
337
,
"w"
:
137
,
"h"
:
167
},
"frame"
:
{
"x"
:
208
,
"y"
:
838
,
"w"
:
137
,
"h"
:
167
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
25
,
"y"
:
10
,
"w"
:
137
,
"h"
:
167
},
"spriteSourceSize"
:
{
"x"
:
25
,
"y"
:
10
,
"w"
:
137
,
"h"
:
167
},
...
@@ -182,7 +209,7 @@
...
@@ -182,7 +209,7 @@
},
},
{
{
"filename"
:
"star_0.png"
,
"filename"
:
"star_0.png"
,
"frame"
:
{
"x"
:
2
04
,
"y"
:
448
,
"w"
:
62
,
"h"
:
62
},
"frame"
:
{
"x"
:
2
,
"y"
:
955
,
"w"
:
62
,
"h"
:
62
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
1
,
"y"
:
1
,
"w"
:
62
,
"h"
:
62
},
"spriteSourceSize"
:
{
"x"
:
1
,
"y"
:
1
,
"w"
:
62
,
"h"
:
62
},
...
@@ -191,7 +218,7 @@
...
@@ -191,7 +218,7 @@
},
},
{
{
"filename"
:
"star_1.png"
,
"filename"
:
"star_1.png"
,
"frame"
:
{
"x"
:
268
,
"y"
:
448
,
"w"
:
62
,
"h"
:
62
},
"frame"
:
{
"x"
:
66
,
"y"
:
955
,
"w"
:
62
,
"h"
:
62
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
1
,
"y"
:
1
,
"w"
:
62
,
"h"
:
62
},
"spriteSourceSize"
:
{
"x"
:
1
,
"y"
:
1
,
"w"
:
62
,
"h"
:
62
},
...
@@ -200,7 +227,7 @@
...
@@ -200,7 +227,7 @@
},
},
{
{
"filename"
:
"star_2.png"
,
"filename"
:
"star_2.png"
,
"frame"
:
{
"x"
:
332
,
"y"
:
448
,
"w"
:
62
,
"h"
:
62
},
"frame"
:
{
"x"
:
130
,
"y"
:
955
,
"w"
:
62
,
"h"
:
62
},
"rotated"
:
false
,
"rotated"
:
false
,
"trimmed"
:
true
,
"trimmed"
:
true
,
"spriteSourceSize"
:
{
"x"
:
1
,
"y"
:
1
,
"w"
:
62
,
"h"
:
62
},
"spriteSourceSize"
:
{
"x"
:
1
,
"y"
:
1
,
"w"
:
62
,
"h"
:
62
},
...
@@ -212,8 +239,8 @@
...
@@ -212,8 +239,8 @@
"version"
:
"1.0"
,
"version"
:
"1.0"
,
"image"
:
"sprites.png"
,
"image"
:
"sprites.png"
,
"format"
:
"RGBA8888"
,
"format"
:
"RGBA8888"
,
"size"
:
{
"w"
:
952
,
"h"
:
512
},
"size"
:
{
"w"
:
509
,
"h"
:
1019
},
"scale"
:
"1"
,
"scale"
:
"1"
,
"smartupdate"
:
"$TexturePacker:SmartUpdate:
342fc72defddab59bb356b48894e2931:ecb4b4fa7772ea6a35788ebf670ca27c
:1eabdf11f75e3a4fe3147baf7b5be24b$"
"smartupdate"
:
"$TexturePacker:SmartUpdate:
2164a72d7de59aa3603277aa505ff73b:f339feca6ccc1f78132ecc733c94dbc5
:1eabdf11f75e3a4fe3147baf7b5be24b$"
}
}
}
}
examples/game/assets/sprites.png
View file @
c7d2872d
This diff was suppressed by a .gitattributes entry.
examples/game/lib/custom_actions.dart
0 → 100644
View file @
c7d2872d
part of
game
;
class
ActionCircularMove
extends
ActionInterval
{
ActionCircularMove
(
this
.
setter
,
this
.
center
,
this
.
radius
,
this
.
startAngle
,
this
.
clockWise
,
double
duration
)
:
super
(
duration
);
final
Function
setter
;
final
Point
center
;
final
double
radius
;
final
double
startAngle
;
final
bool
clockWise
;
void
update
(
double
t
)
{
if
(!
clockWise
)
t
=
-
t
;
double
rad
=
radians
(
startAngle
+
t
*
360.0
);
Offset
offset
=
new
Offset
(
math
.
cos
(
rad
)
*
radius
,
math
.
sin
(
rad
)
*
radius
);
Point
pos
=
center
+
offset
;
setter
(
pos
);
}
}
examples/game/lib/explosions.dart
View file @
c7d2872d
part of
game
;
part of
game
;
class
Explosion
extends
Node
{
class
Explosion
extends
Node
{
Explosion
(
SpriteSheet
sheet
)
{
Explosion
()
{
zPosition
=
10.0
;
}
}
class
ExplosionBig
extends
Explosion
{
ExplosionBig
(
SpriteSheet
sheet
)
{
// Add particles
// Add particles
ParticleSystem
particlesDebris
=
new
ParticleSystem
(
ParticleSystem
particlesDebris
=
new
ParticleSystem
(
sheet
[
"explosion_particle.png"
],
sheet
[
"explosion_particle.png"
],
...
@@ -69,3 +75,7 @@ class Explosion extends Node {
...
@@ -69,3 +75,7 @@ class Explosion extends Node {
}
}
}
}
}
}
class
ExplosionMini
extends
Explosion
{
}
examples/game/lib/game_demo.dart
View file @
c7d2872d
...
@@ -7,7 +7,9 @@ import 'dart:sky' as sky;
...
@@ -7,7 +7,9 @@ import 'dart:sky' as sky;
import
'package:sky/rendering/object.dart'
;
import
'package:sky/rendering/object.dart'
;
import
'package:sky/widgets/framework.dart'
;
import
'package:sky/widgets/framework.dart'
;
import
'package:skysprites/skysprites.dart'
;
import
'package:skysprites/skysprites.dart'
;
import
'package:vector_math/vector_math.dart'
;
part
'custom_actions.dart'
;
part
'explosions.dart'
;
part
'explosions.dart'
;
part
'flash.dart'
;
part
'flash.dart'
;
part
'game_demo_node.dart'
;
part
'game_demo_node.dart'
;
...
...
examples/game/lib/game_demo_node.dart
View file @
c7d2872d
...
@@ -198,11 +198,11 @@ class GameDemoNode extends NodeWithSize {
...
@@ -198,11 +198,11 @@ class GameDemoNode extends NodeWithSize {
if
(
part
==
0
)
{
if
(
part
==
0
)
{
_objectFactory
.
addAsteroids
(
10
+
level
*
4
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
));
_objectFactory
.
addAsteroids
(
10
+
level
*
4
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
));
}
else
if
(
part
==
1
)
{
}
else
if
(
part
==
1
)
{
_objectFactory
.
addSwarm
(
4
+
level
*
2
,
yPos
);
_objectFactory
.
add
EnemyScout
Swarm
(
4
+
level
*
2
,
yPos
);
}
else
if
(
part
==
2
)
{
}
else
if
(
part
==
2
)
{
_objectFactory
.
addAsteroids
(
10
+
level
*
4
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
));
_objectFactory
.
addAsteroids
(
10
+
level
*
4
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
));
}
else
if
(
part
==
3
)
{
}
else
if
(
part
==
3
)
{
_objectFactory
.
add
Asteroids
(
10
+
level
*
4
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
)
);
_objectFactory
.
add
EnemyDestroyerSwarm
(
2
+
level
,
yPos
);
}
else
if
(
part
==
4
)
{
}
else
if
(
part
==
4
)
{
_objectFactory
.
addAsteroids
(
10
+
level
*
4
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
));
_objectFactory
.
addAsteroids
(
10
+
level
*
4
,
yPos
,
0.0
+
(
level
*
0.2
).
clamp
(
0.0
,
0.7
));
}
}
...
@@ -227,7 +227,7 @@ class GameDemoNode extends NodeWithSize {
...
@@ -227,7 +227,7 @@ class GameDemoNode extends NodeWithSize {
_effectPlayer
.
play
(
_sounds
[
"explosion"
]);
_effectPlayer
.
play
(
_sounds
[
"explosion"
]);
// Add explosion
// Add explosion
Explosion
explo
=
new
Explosion
(
_spritesGame
);
Explosion
Big
explo
=
new
ExplosionBig
(
_spritesGame
);
explo
.
scale
=
1.5
;
explo
.
scale
=
1.5
;
explo
.
position
=
_level
.
ship
.
position
;
explo
.
position
=
_level
.
ship
.
position
;
_level
.
addChild
(
explo
);
_level
.
addChild
(
explo
);
...
...
examples/game/lib/game_object_factory.dart
View file @
c7d2872d
...
@@ -3,7 +3,8 @@ part of game;
...
@@ -3,7 +3,8 @@ part of game;
enum
GameObjectType
{
enum
GameObjectType
{
asteroidBig
,
asteroidBig
,
asteroidSmall
,
asteroidSmall
,
movingEnemy
,
enemyScout
,
enemyDestroyer
,
coin
,
coin
,
}
}
...
@@ -24,11 +25,17 @@ class GameObjectFactory {
...
@@ -24,11 +25,17 @@ class GameObjectFactory {
}
}
}
}
void
addSwarm
(
int
numEnemies
,
double
yPos
)
{
void
add
EnemyScout
Swarm
(
int
numEnemies
,
double
yPos
)
{
for
(
int
i
=
0
;
i
<
numEnemies
;
i
++)
{
for
(
int
i
=
0
;
i
<
numEnemies
;
i
++)
{
double
spacing
=
math
.
max
(
_chunkSpacing
/
(
numEnemies
+
1.0
),
80.0
);
double
spacing
=
math
.
max
(
_chunkSpacing
/
(
numEnemies
+
1.0
),
80.0
);
double
y
=
yPos
+
_chunkSpacing
/
2.0
-
(
numEnemies
-
1
)
*
spacing
/
2.0
+
i
*
spacing
;
double
y
=
yPos
+
_chunkSpacing
/
2.0
-
(
numEnemies
-
1
)
*
spacing
/
2.0
+
i
*
spacing
;
addGameObject
(
GameObjectType
.
movingEnemy
,
new
Point
(
0.0
,
y
));
addGameObject
(
GameObjectType
.
enemyScout
,
new
Point
(
0.0
,
y
));
}
}
void
addEnemyDestroyerSwarm
(
int
numEnemies
,
double
yPos
)
{
for
(
int
i
=
0
;
i
<
numEnemies
;
i
++)
{
addGameObject
(
GameObjectType
.
enemyDestroyer
,
new
Point
(
randomSignedDouble
()
*
120.0
,
yPos
+
_chunkSpacing
*
randomDouble
()));
}
}
}
}
...
@@ -38,8 +45,10 @@ class GameObjectFactory {
...
@@ -38,8 +45,10 @@ class GameObjectFactory {
obj
=
new
AsteroidBig
(
this
);
obj
=
new
AsteroidBig
(
this
);
else
if
(
type
==
GameObjectType
.
asteroidSmall
)
else
if
(
type
==
GameObjectType
.
asteroidSmall
)
obj
=
new
AsteroidSmall
(
this
);
obj
=
new
AsteroidSmall
(
this
);
else
if
(
type
==
GameObjectType
.
movingEnemy
)
else
if
(
type
==
GameObjectType
.
enemyScout
)
obj
=
new
MovingEnemy
(
this
);
obj
=
new
EnemyScout
(
this
);
else
if
(
type
==
GameObjectType
.
enemyDestroyer
)
obj
=
new
EnemyDestroyer
(
this
);
else
if
(
type
==
GameObjectType
.
coin
)
else
if
(
type
==
GameObjectType
.
coin
)
obj
=
new
Coin
(
this
);
obj
=
new
Coin
(
this
);
...
...
examples/game/lib/game_objects.dart
View file @
c7d2872d
...
@@ -120,8 +120,9 @@ class Laser extends GameObject {
...
@@ -120,8 +120,9 @@ class Laser extends GameObject {
Laser
(
GameObjectFactory
f
)
:
super
(
f
)
{
Laser
(
GameObjectFactory
f
)
:
super
(
f
)
{
// Add sprite
// Add sprite
_sprt
=
new
Sprite
(
f
.
sheet
[
"laser.png"
]);
_sprt
=
new
Sprite
(
f
.
sheet
[
"explosion_particle.png"
]);
_sprt
.
scale
=
0.3
;
_sprt
.
scale
=
0.5
;
_sprt
.
colorOverlay
=
new
Color
(
0xff95f4fb
);
_sprt
.
transferMode
=
sky
.
TransferMode
.
plus
;
_sprt
.
transferMode
=
sky
.
TransferMode
.
plus
;
addChild
(
_sprt
);
addChild
(
_sprt
);
radius
=
10.0
;
radius
=
10.0
;
...
@@ -138,6 +139,11 @@ class Laser extends GameObject {
...
@@ -138,6 +139,11 @@ class Laser extends GameObject {
}
}
}
}
Color
colorForDamage
(
double
damage
,
double
maxDamage
)
{
int
alpha
=
((
200.0
*
damage
)
~/
maxDamage
).
clamp
(
0
,
200
);
return
new
Color
.
fromARGB
(
alpha
,
255
,
3
,
86
);
}
abstract
class
Obstacle
extends
GameObject
{
abstract
class
Obstacle
extends
GameObject
{
Obstacle
(
GameObjectFactory
f
)
:
super
(
f
);
Obstacle
(
GameObjectFactory
f
)
:
super
(
f
);
...
@@ -146,7 +152,7 @@ abstract class Obstacle extends GameObject {
...
@@ -146,7 +152,7 @@ abstract class Obstacle extends GameObject {
Explosion
createExplosion
()
{
Explosion
createExplosion
()
{
SoundEffectPlayer
.
sharedInstance
().
play
(
f
.
sounds
[
"explosion"
]);
SoundEffectPlayer
.
sharedInstance
().
play
(
f
.
sounds
[
"explosion"
]);
Explosion
explo
=
new
Explosion
(
f
.
sheet
);
Explosion
explo
=
new
Explosion
Big
(
f
.
sheet
);
explo
.
scale
=
explosionScale
;
explo
.
scale
=
explosionScale
;
return
explo
;
return
explo
;
}
}
...
@@ -169,8 +175,7 @@ abstract class Asteroid extends Obstacle {
...
@@ -169,8 +175,7 @@ abstract class Asteroid extends Obstacle {
set
damage
(
double
d
)
{
set
damage
(
double
d
)
{
super
.
damage
=
d
;
super
.
damage
=
d
;
int
alpha
=
((
200.0
*
d
)
~/
maxDamage
).
clamp
(
0
,
200
);
_sprt
.
colorOverlay
=
colorForDamage
(
d
,
maxDamage
);
_sprt
.
colorOverlay
=
new
Color
.
fromARGB
(
alpha
,
255
,
3
,
86
);
}
}
PowerUp
createPowerUp
()
{
PowerUp
createPowerUp
()
{
...
@@ -198,10 +203,10 @@ class AsteroidSmall extends Asteroid {
...
@@ -198,10 +203,10 @@ class AsteroidSmall extends Asteroid {
}
}
}
}
class
MovingEnemy
extends
Obstacle
{
class
EnemyScout
extends
Obstacle
{
MovingEnemy
(
GameObjectFactory
f
)
:
super
(
f
)
{
EnemyScout
(
GameObjectFactory
f
)
:
super
(
f
)
{
_sprt
=
new
Sprite
(
f
.
sheet
[
"
ship
.png"
]);
_sprt
=
new
Sprite
(
f
.
sheet
[
"
enemy_scout_0
.png"
]);
_sprt
.
scale
=
0.2
;
_sprt
.
scale
=
0.
3
2
;
radius
=
12.0
;
radius
=
12.0
;
maxDamage
=
1.0
;
maxDamage
=
1.0
;
addChild
(
_sprt
);
addChild
(
_sprt
);
...
@@ -251,9 +256,87 @@ class MovingEnemy extends Obstacle {
...
@@ -251,9 +256,87 @@ class MovingEnemy extends Obstacle {
actions
.
run
(
new
ActionRepeatForever
(
spline
));
actions
.
run
(
new
ActionRepeatForever
(
spline
));
}
}
PowerUp
createPowerUp
()
{
return
new
Coin
(
f
);
}
Sprite
_sprt
;
}
class
EnemyDestroyer
extends
Obstacle
{
EnemyDestroyer
(
GameObjectFactory
f
)
:
super
(
f
)
{
_sprt
=
new
Sprite
(
f
.
sheet
[
"enemy_destroyer_1.png"
]);
_sprt
.
scale
=
0.32
;
radius
=
24.0
;
maxDamage
=
4.0
;
addChild
(
_sprt
);
constraints
=
[
new
ConstraintRotationToNode
(
f
.
level
.
ship
,
dampening:
0.05
)];
}
int
_countDown
=
randomInt
(
120
)
+
240
;
void
setupActions
()
{
ActionCircularMove
circle
=
new
ActionCircularMove
(
(
a
)
=>
position
=
a
,
position
,
40.0
,
360.0
*
randomDouble
(),
randomBool
(),
3.0
);
actions
.
run
(
new
ActionRepeatForever
(
circle
));
}
PowerUp
createPowerUp
()
{
return
new
Coin
(
f
);
}
void
update
(
double
dt
)
{
_countDown
-=
1
;
if
(
_countDown
<=
0
)
{
print
(
"SHOOT!!"
);
// Shoot at player
EnemyLaser
laser
=
new
EnemyLaser
(
f
,
rotation
,
5.0
,
new
Color
(
0xffffe38e
));
laser
.
position
=
position
;
f
.
level
.
addChild
(
laser
);
_countDown
=
60
+
randomInt
(
120
);
}
}
set
damage
(
double
d
)
{
super
.
damage
=
d
;
_sprt
.
colorOverlay
=
colorForDamage
(
d
,
maxDamage
);
}
Sprite
_sprt
;
Sprite
_sprt
;
}
}
class
EnemyLaser
extends
Obstacle
{
EnemyLaser
(
GameObjectFactory
f
,
double
rotation
,
double
speed
,
Color
color
)
:
super
(
f
)
{
_sprt
=
new
Sprite
(
f
.
sheet
[
"explosion_particle.png"
]);
_sprt
.
scale
=
0.5
;
_sprt
.
rotation
=
rotation
+
90
;
_sprt
.
colorOverlay
=
color
;
addChild
(
_sprt
);
canDamageShip
=
true
;
canBeDamaged
=
false
;
double
rad
=
radians
(
rotation
);
_movement
=
new
Offset
(
math
.
cos
(
rad
)
*
speed
,
math
.
sin
(
rad
)
*
speed
);
print
(
"LASER!!"
);
}
Sprite
_sprt
;
Offset
_movement
;
void
move
()
{
position
+=
_movement
;
}
}
class
PowerUp
extends
GameObject
{
class
PowerUp
extends
GameObject
{
PowerUp
(
GameObjectFactory
f
)
:
super
(
f
)
{
PowerUp
(
GameObjectFactory
f
)
:
super
(
f
)
{
canDamageShip
=
false
;
canDamageShip
=
false
;
...
@@ -264,10 +347,8 @@ class PowerUp extends GameObject {
...
@@ -264,10 +347,8 @@ class PowerUp extends GameObject {
class
Coin
extends
PowerUp
{
class
Coin
extends
PowerUp
{
Coin
(
GameObjectFactory
f
)
:
super
(
f
)
{
Coin
(
GameObjectFactory
f
)
:
super
(
f
)
{
_sprt
=
new
Sprite
(
f
.
sheet
[
"shield.png"
]);
_sprt
=
new
Sprite
(
f
.
sheet
[
"coin.png"
]);
_sprt
.
transferMode
=
sky
.
TransferMode
.
plus
;
_sprt
.
scale
=
0.7
;
_sprt
.
size
=
new
Size
(
15.0
,
15.0
);
_sprt
.
colorOverlay
=
new
Color
(
0xffffff00
);
addChild
(
_sprt
);
addChild
(
_sprt
);
radius
=
7.5
;
radius
=
7.5
;
...
...
examples/game/lib/player_state.dart
View file @
c7d2872d
...
@@ -3,38 +3,41 @@ part of game;
...
@@ -3,38 +3,41 @@ part of game;
class
PlayerState
extends
Node
{
class
PlayerState
extends
Node
{
PlayerState
(
this
.
_sheetUI
,
this
.
_sheetGame
)
{
PlayerState
(
this
.
_sheetUI
,
this
.
_sheetGame
)
{
// Score display
// Score display
Sprite
sprtBgScore
=
new
Sprite
(
_sheetUI
[
"scoreboard.png"
]);
_
sprtBgScore
=
new
Sprite
(
_sheetUI
[
"scoreboard.png"
]);
sprtBgScore
.
pivot
=
new
Point
(
1.0
,
0.0
);
_
sprtBgScore
.
pivot
=
new
Point
(
1.0
,
0.0
);
sprtBgScore
.
scale
=
0.35
;
_
sprtBgScore
.
scale
=
0.35
;
sprtBgScore
.
position
=
new
Point
(
31
0.0
,
10.0
);
_sprtBgScore
.
position
=
new
Point
(
24
0.0
,
10.0
);
addChild
(
sprtBgScore
);
addChild
(
_
sprtBgScore
);
_scoreDisplay
=
new
ScoreDisplay
(
_sheetUI
);
_scoreDisplay
=
new
ScoreDisplay
(
_sheetUI
);
_scoreDisplay
.
position
=
new
Point
(-
13.0
,
49.0
);
_scoreDisplay
.
position
=
new
Point
(-
13.0
,
49.0
);
sprtBgScore
.
addChild
(
_scoreDisplay
);
_
sprtBgScore
.
addChild
(
_scoreDisplay
);
// Coin display
// Coin display
Sprite
sprtBgCoins
=
new
Sprite
(
_sheetUI
[
"score
board.png"
]);
_sprtBgCoins
=
new
Sprite
(
_sheetUI
[
"coin
board.png"
]);
sprtBgCoins
.
pivot
=
new
Point
(
1.0
,
0.0
);
_
sprtBgCoins
.
pivot
=
new
Point
(
1.0
,
0.0
);
sprtBgCoins
.
scale
=
0.35
;
_
sprtBgCoins
.
scale
=
0.35
;
sprtBgCoins
.
position
=
new
Point
(
170
.0
,
10.0
);
_sprtBgCoins
.
position
=
new
Point
(
105
.0
,
10.0
);
addChild
(
sprtBgCoins
);
addChild
(
_
sprtBgCoins
);
_coinDisplay
=
new
ScoreDisplay
(
_sheetUI
);
_coinDisplay
=
new
ScoreDisplay
(
_sheetUI
);
_coinDisplay
.
position
=
new
Point
(-
13.0
,
49.0
);
_coinDisplay
.
position
=
new
Point
(-
13.0
,
49.0
);
sprtBgCoins
.
addChild
(
_coinDisplay
);
_
sprtBgCoins
.
addChild
(
_coinDisplay
);
}
}
final
SpriteSheet
_sheetUI
;
final
SpriteSheet
_sheetUI
;
final
SpriteSheet
_sheetGame
;
final
SpriteSheet
_sheetGame
;
Sprite
_sprtBgScore
;
ScoreDisplay
_scoreDisplay
;
ScoreDisplay
_scoreDisplay
;
Sprite
_sprtBgCoins
;
ScoreDisplay
_coinDisplay
;
ScoreDisplay
_coinDisplay
;
int
get
score
=>
_scoreDisplay
.
score
;
int
get
score
=>
_scoreDisplay
.
score
;
set
score
(
int
score
)
{
set
score
(
int
score
)
{
_scoreDisplay
.
score
=
score
;
_scoreDisplay
.
score
=
score
;
flashBgSprite
(
_sprtBgScore
);
}
}
int
get
coins
=>
_coinDisplay
.
score
;
int
get
coins
=>
_coinDisplay
.
score
;
...
@@ -42,26 +45,41 @@ class PlayerState extends Node {
...
@@ -42,26 +45,41 @@ class PlayerState extends Node {
void
addCoin
(
Coin
c
)
{
void
addCoin
(
Coin
c
)
{
// Animate coin to the top of the screen
// Animate coin to the top of the screen
Point
startPos
=
convertPointFromNode
(
Point
.
origin
,
c
);
Point
startPos
=
convertPointFromNode
(
Point
.
origin
,
c
);
Point
finalPos
=
new
Point
(
10.0
,
1
0.0
);
Point
finalPos
=
new
Point
(
30.0
,
3
0.0
);
Point
middlePos
=
new
Point
((
startPos
.
x
+
finalPos
.
x
)
/
2.0
+
50.0
,
Point
middlePos
=
new
Point
((
startPos
.
x
+
finalPos
.
x
)
/
2.0
+
50.0
,
(
startPos
.
y
+
finalPos
.
y
)
/
2.0
);
(
startPos
.
y
+
finalPos
.
y
)
/
2.0
);
List
<
Point
>
path
=
[
startPos
,
middlePos
,
finalPos
];
List
<
Point
>
path
=
[
startPos
,
middlePos
,
finalPos
];
Sprite
sprt
=
new
Sprite
(
_sheetGame
[
"shield.png"
]);
Sprite
sprt
=
new
Sprite
(
_sheetGame
[
"coin.png"
]);
sprt
.
size
=
new
Size
(
15.0
,
15.0
);
sprt
.
scale
=
0.7
;
sprt
.
transferMode
=
sky
.
TransferMode
.
plus
;
sprt
.
colorOverlay
=
new
Color
(
0xffffff00
);
ActionSpline
spline
=
new
ActionSpline
((
a
)
=>
sprt
.
position
=
a
,
path
,
0.5
);
ActionSpline
spline
=
new
ActionSpline
((
a
)
=>
sprt
.
position
=
a
,
path
,
0.5
);
spline
.
tension
=
0.25
;
spline
.
tension
=
0.25
;
ActionTween
rotate
=
new
ActionTween
((
a
)
=>
sprt
.
rotation
=
a
,
0.0
,
360.0
,
0.5
);
ActionTween
scale
=
new
ActionTween
((
a
)
=>
sprt
.
scale
=
a
,
0.7
,
1.2
,
0.5
);
ActionGroup
group
=
new
ActionGroup
([
spline
,
rotate
,
scale
]);
sprt
.
actions
.
run
(
new
ActionSequence
([
sprt
.
actions
.
run
(
new
ActionSequence
([
spline
,
group
,
new
ActionRemoveNode
(
sprt
),
new
ActionRemoveNode
(
sprt
),
new
ActionCallFunction
(()
{
_coinDisplay
.
score
+=
1
;
})
new
ActionCallFunction
(()
{
_coinDisplay
.
score
+=
1
;
flashBgSprite
(
_sprtBgCoins
);
})
]));
]));
addChild
(
sprt
);
addChild
(
sprt
);
}
}
void
flashBgSprite
(
Sprite
sprt
)
{
sprt
.
actions
.
stopAll
();
ActionTween
flash
=
new
ActionTween
(
(
a
)
=>
sprt
.
colorOverlay
=
a
,
new
Color
(
0x66ccfff0
),
new
Color
(
0x00ccfff0
),
0.3
);
sprt
.
actions
.
run
(
flash
);
}
}
}
class
ScoreDisplay
extends
Node
{
class
ScoreDisplay
extends
Node
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment