[fix] Fixed an issue that sjplayer.Context wasn't destroyed after end of the game.

This commit is contained in:
falsycat 2019-10-14 00:00:00 +00:00
parent 2345cfb22a
commit 47ede702f6
2 changed files with 11 additions and 5 deletions

View File

@ -42,15 +42,16 @@ class PlayScene : SceneInterface {
music_.PlayForGame(); music_.PlayForGame();
} }
override SceneInterface Update(KeyInput input) { override SceneInterface Update(KeyInput input) {
const beat = music_.beat; beat_ = music_.beat;
if (beat >= context_.length) { if (beat_ >= context_.length) {
music_.StopPlaying(); music_.StopPlaying();
result_scene_.Initialize(music_, score_); result_scene_.Initialize(music_, score_);
return result_scene_; return result_scene_;
} }
context_.OperateScheduledControllers(beat); context_.OperateScheduledControllers(beat_);
context_.actor.Accelarate(GetAccelarationFromKeyInput(input)); context_.actor.Accelarate(GetAccelarationFromKeyInput(input));
@ -78,6 +79,10 @@ class PlayScene : SceneInterface {
context_.DrawActor(); context_.DrawActor();
context_.EndDrawing(); context_.EndDrawing();
if (beat_ >= context_.length) {
context_.destroy();
}
} }
private: private:
@ -95,5 +100,6 @@ class PlayScene : SceneInterface {
Music music_; Music music_;
sjplayer.Context context_; sjplayer.Context context_;
int score_; float beat_;
int score_;
} }

View File

@ -65,7 +65,7 @@ class TitleScene : SceneInterface {
lobby_.cube_interval = cube_interval_ease_.Calculate(ratio); lobby_.cube_interval = cube_interval_ease_.Calculate(ratio);
if (input.down) { if (anime_.isFinished && input.down) {
select_scene_.Initialize(); select_scene_.Initialize();
return select_scene_; return select_scene_;
} }