Skip to content

Commit d1be6ae

Browse files
committed
fix voice
1 parent be91d89 commit d1be6ae

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

lib/gamer/gamer.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class Game extends StatefulWidget {
5757
}
5858
}
5959

60-
///duration for show a line when reseting
60+
///duration for show a line when reset
6161
const _REST_LINE_DURATION = const Duration(milliseconds: 50);
6262

6363
const _LEVEL_MAX = 6;
@@ -87,10 +87,10 @@ class GameControl extends State<Game> {
8787

8888
///在 [build] 方法中于 [_data]混合,形成一个新的矩阵
8989
///[_mask]矩阵的宽高与 [_data] 一致
90-
///对于任意的 _shinning[x,y]
90+
///对于任意的 _mask[x,y]
9191
/// 如果值为 0,则对 [_data]没有任何影响
9292
/// 如果值为 -1,则表示 [_data] 中该行不显示
93-
/// 如果值为 1,则表示 [_data] 中改行高亮
93+
/// 如果值为 1,则表示 [_data] 中该行高亮
9494
final List<List<int>> _mask = [];
9595

9696
///from 1-6
@@ -154,12 +154,11 @@ class GameControl extends State<Game> {
154154
for (int i = 0; i < GAME_PAD_MATRIX_H; i++) {
155155
final fall = _current.fall(step: i + 1);
156156
if (!fall.isValidInMatrix(_data)) {
157-
sounds.fall();
158157
_current = _current.fall(step: i);
159158
_states = GameStates.drop;
160159
setState(() {});
161160
await Future.delayed(const Duration(milliseconds: 100));
162-
_mixCurrentIntoData();
161+
_mixCurrentIntoData(mixSound: sounds.fall);
163162
break;
164163
}
165164
}
@@ -187,7 +186,7 @@ class GameControl extends State<Game> {
187186
Timer _autoFallTimer;
188187

189188
///mix current into [_data]
190-
Future<void> _mixCurrentIntoData() async {
189+
Future<void> _mixCurrentIntoData({void mixSound()}) async {
191190
if (_current == null) {
192191
return;
193192
}
@@ -235,6 +234,7 @@ class GameControl extends State<Game> {
235234
_level = level <= _LEVEL_MAX && level > _level ? level : _level;
236235
} else {
237236
_states = GameStates.mixing;
237+
if (mixSound != null) mixSound();
238238
_forTable((i, j) => _mask[i][j] = _current.get(j, i) ?? _mask[i][j]);
239239
setState(() {});
240240
await Future.delayed(const Duration(milliseconds: 200));

lib/material/audios.dart

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,9 @@ class Sounds {
3737
final player = _audioPlayer.fixedPlayer;
3838
await player.seek(start);
3939
await player.resume();
40-
final end = start + length;
41-
player.positionHandler = (duration) {
42-
if (duration >= end) {
43-
player.pause();
44-
_playing = false;
45-
}
46-
};
40+
await Future.delayed(length);
41+
player.pause();
42+
_playing = false;
4743
}
4844

4945
void start() {

0 commit comments

Comments
 (0)