From 05377b7472f424d098ff98ce1f0e3aea4aa3f571 Mon Sep 17 00:00:00 2001 From: falsycat Date: Wed, 16 Oct 2019 00:00:00 +0000 Subject: [PATCH] [fix] Fixed an issue that posteffect's parameters were remained after music ended. --- sjplayer/src/sjplayer/PostEffect.d | 5 +++++ src/sj/Game.d | 2 +- src/sj/PlayScene.d | 7 ++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sjplayer/src/sjplayer/PostEffect.d b/sjplayer/src/sjplayer/PostEffect.d index bd2e59f..5ece992 100644 --- a/sjplayer/src/sjplayer/PostEffect.d +++ b/sjplayer/src/sjplayer/PostEffect.d @@ -60,6 +60,11 @@ class PostEffect { fb_.Unbind(); } + /// + void Initialize() { + instance = instance.init; + } + /// void BindFramebuffer() { fb_.Bind(); diff --git a/src/sj/Game.d b/src/sj/Game.d index 6836b6a..96f78ec 100644 --- a/src/sj/Game.d +++ b/src/sj/Game.d @@ -48,7 +48,7 @@ class Game : AbstractGame { title_ = new TitleScene(lobby_, programs_); select_ = new SelectScene(lobby_, programs_, fonts_, music_list_); load_ = new LoadingScene(lobby_, posteffect_, programs_, fonts_); - play_ = new PlayScene; + play_ = new PlayScene(posteffect_); result_ = new ResultScene(lobby_, programs_, fonts_); title_ .SetupSceneDependency(select_); diff --git a/src/sj/PlayScene.d b/src/sj/PlayScene.d index c33ecb3..5acfde0 100644 --- a/src/sj/PlayScene.d +++ b/src/sj/PlayScene.d @@ -23,7 +23,8 @@ class PlayScene : SceneInterface { enum NearnessScoreRatio = 10; /// - this() { + this(sjplayer.PostEffect posteffect) { + posteffect_ = posteffect; } ~this() { context_.destroy(); @@ -42,12 +43,14 @@ class PlayScene : SceneInterface { score_ = BaseScore; music_.PlayForGame(offset_beat); + posteffect_.Initialize(); } override SceneInterface Update(KeyInput input) { beat_ = music_.beat; if (beat_ >= context_.length) { music_.StopPlaying(); + posteffect_.Initialize(); result_scene_.Initialize(music_, score_); return result_scene_; @@ -93,6 +96,8 @@ class PlayScene : SceneInterface { return result; } + sjplayer.PostEffect posteffect_; + ResultScene result_scene_; Music music_;