mirror of
https://github.com/flutter/samples.git
synced 2025-11-13 00:08:24 +00:00
Add game_template (#1180)
Adds a template / sample for games built in Flutter, with all the bells and whistles, like ads, in-app purchases, audio, main menu, settings, and so on. Co-authored-by: Parker Lougheed Co-authored-by: Shams Zakhour
This commit is contained in:
71
game_template/lib/src/audio/sounds.dart
Normal file
71
game_template/lib/src/audio/sounds.dart
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright 2022, the Flutter project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
List<String> soundTypeToFilename(SfxType type) {
|
||||
switch (type) {
|
||||
case SfxType.huhsh:
|
||||
return const [
|
||||
'hash1.mp3',
|
||||
'hash2.mp3',
|
||||
'hash3.mp3',
|
||||
];
|
||||
case SfxType.wssh:
|
||||
return const [
|
||||
'wssh1.mp3',
|
||||
'wssh2.mp3',
|
||||
'dsht1.mp3',
|
||||
'ws1.mp3',
|
||||
'spsh1.mp3',
|
||||
'hh1.mp3',
|
||||
'hh2.mp3',
|
||||
'kss1.mp3',
|
||||
];
|
||||
case SfxType.buttonTap:
|
||||
return const [
|
||||
'k1.mp3',
|
||||
'k2.mp3',
|
||||
'p1.mp3',
|
||||
'p2.mp3',
|
||||
];
|
||||
case SfxType.congrats:
|
||||
return const [
|
||||
'yay1.mp3',
|
||||
'wehee1.mp3',
|
||||
'oo1.mp3',
|
||||
];
|
||||
case SfxType.erase:
|
||||
return const [
|
||||
'fwfwfwfwfw1.mp3',
|
||||
'fwfwfwfw1.mp3',
|
||||
];
|
||||
case SfxType.swishSwish:
|
||||
return const [
|
||||
'swishswish1.mp3',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/// Allows control over loudness of different SFX types.
|
||||
double soundTypeToVolume(SfxType type) {
|
||||
switch (type) {
|
||||
case SfxType.huhsh:
|
||||
return 0.4;
|
||||
case SfxType.wssh:
|
||||
return 0.2;
|
||||
case SfxType.buttonTap:
|
||||
case SfxType.congrats:
|
||||
case SfxType.erase:
|
||||
case SfxType.swishSwish:
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
enum SfxType {
|
||||
huhsh,
|
||||
wssh,
|
||||
buttonTap,
|
||||
congrats,
|
||||
erase,
|
||||
swishSwish,
|
||||
}
|
||||
Reference in New Issue
Block a user