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
b529445f
Commit
b529445f
authored
Aug 13, 2015
by
Viktor Lidholt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds sounds to demo game
parent
86a8e06a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
game_demo_world.dart
examples/game/lib/game_demo_world.dart
+9
-1
main.dart
examples/game/lib/main.dart
+8
-0
No files found.
examples/game/lib/game_demo_world.dart
View file @
b529445f
...
...
@@ -28,6 +28,10 @@ class GameDemoWorld extends NodeWithSize {
SpriteSheet
_spriteSheet
;
SpriteSheet
_spriteSheetUI
;
Map
<
String
,
SoundEffect
>
_sounds
;
SoundPool
_soundPool
=
SoundPool
.
sharedInstance
();
Navigator
_navigator
;
// Inputs
...
...
@@ -54,7 +58,7 @@ class GameDemoWorld extends NodeWithSize {
Function
_gameOverCallback
;
GameDemoWorld
(
App
app
,
this
.
_navigator
,
ImageMap
images
,
this
.
_spriteSheet
,
this
.
_spriteSheetUI
,
this
.
_gameOverCallback
)
:
super
(
new
Size
(
_gameSizeWidth
,
_gameSizeHeight
))
{
GameDemoWorld
(
App
app
,
this
.
_navigator
,
ImageMap
images
,
this
.
_spriteSheet
,
this
.
_spriteSheetUI
,
this
.
_
sounds
,
this
.
_
gameOverCallback
)
:
super
(
new
Size
(
_gameSizeWidth
,
_gameSizeHeight
))
{
// Fetch images
_imgNebula
=
images
[
"assets/nebula.png"
];
...
...
@@ -140,6 +144,8 @@ class GameDemoWorld extends NodeWithSize {
laser
.
constrainProportions
=
true
;
_lasers
.
add
(
laser
);
_gameLayer
.
addChild
(
laser
);
_soundPool
.
play
(
_sounds
[
"laser"
]);
}
void
addNebula
()
{
...
...
@@ -225,6 +231,8 @@ class GameDemoWorld extends NodeWithSize {
}
_gameLayer
.
addChild
(
explosionNode
);
_soundPool
.
play
(
_sounds
[
"explosion"
]);
}
void
update
(
double
dt
)
{
...
...
examples/game/lib/main.dart
View file @
b529445f
...
...
@@ -28,6 +28,7 @@ ImageMap _loader;
SpriteSheet
_spriteSheet
;
SpriteSheet
_spriteSheetUI
;
GameDemoApp
_app
;
Map
<
String
,
SoundEffect
>
_sounds
=
{};
main
()
async
{
_loader
=
new
ImageMap
(
_bundle
);
...
...
@@ -47,6 +48,12 @@ main() async {
_app
=
new
GameDemoApp
();
_sounds
[
"explosion"
]
=
new
SoundEffect
(
'https://github.com/slembcke/GalacticGuardian.spritebuilder/raw/GDC/Packages/SpriteBuilder%20Resources.sbpack/TempSounds/Explosion.wav'
);
_sounds
[
"laser"
]
=
new
SoundEffect
(
'https://github.com/slembcke/GalacticGuardian.spritebuilder/raw/GDC/Packages/SpriteBuilder%20Resources.sbpack/TempSounds/Laser.wav'
);
await
_sounds
[
"explosion"
].
load
();
await
_sounds
[
"laser"
].
load
();
runApp
(
_app
);
}
...
...
@@ -103,6 +110,7 @@ class GameDemoApp extends App {
_loader
,
_spriteSheet
,
_spriteSheetUI
,
_sounds
,
(
lastScore
)
{
setState
(()
{
_lastScore
=
lastScore
;});
}
...
...
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