From 814c563c556e7cadcb2915b39d99d9053e00a269 Mon Sep 17 00:00:00 2001 From: MAJigsaw77 <77043862+MAJigsaw77@users.noreply.github.com> Date: Sat, 7 Jun 2025 16:38:38 +0300 Subject: [PATCH] Move gameover ads loading to gameover state. --- source/funkin/play/GameOverSubState.hx | 22 +++++++++++++++++++ source/funkin/play/PlayState.hx | 29 -------------------------- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/source/funkin/play/GameOverSubState.hx b/source/funkin/play/GameOverSubState.hx index 8d85b316e..fd385b9b9 100644 --- a/source/funkin/play/GameOverSubState.hx +++ b/source/funkin/play/GameOverSubState.hx @@ -22,6 +22,9 @@ import funkin.effects.RetroCameraFade; import flixel.math.FlxPoint; import funkin.util.TouchUtil; import openfl.utils.Assets; +#if FEATURE_MOBILE_ADVERTISEMENTS +import funkin.mobile.util.AdMobUtil; +#end /** * A substate which renders over the PlayState when the player dies. @@ -408,13 +411,32 @@ class GameOverSubState extends MusicBeatSubState RetroCameraFade.fadeToBlack(FlxG.camera, 10, 2); new FlxTimer().start(2, _ -> { FlxG.camera.filters = []; + + #if FEATURE_MOBILE_ADVERTISEMENTS + if (Constants.GLOBAL_BLUEBALL_COUNTER > 0 && Constants.GLOBAL_BLUEBALL_COUNTER % 3 == 0) + { + AdMobUtil.loadInterstitial(resetPlaying.bind(true)); + } + else + resetPlaying(true); + #else resetPlaying(true); + #end }); } else { FlxG.camera.fade(FlxColor.BLACK, 2, false, function() { + #if FEATURE_MOBILE_ADVERTISEMENTS + if (Constants.GLOBAL_BLUEBALL_COUNTER > 0 && Constants.GLOBAL_BLUEBALL_COUNTER % 3 == 0) + { + AdMobUtil.loadInterstitial(resetPlaying.bind()); + } + else + resetPlaying(); + #else resetPlaying(); + #end }); } }); diff --git a/source/funkin/play/PlayState.hx b/source/funkin/play/PlayState.hx index fc125ca81..987495494 100644 --- a/source/funkin/play/PlayState.hx +++ b/source/funkin/play/PlayState.hx @@ -1250,34 +1250,6 @@ class PlayState extends MusicBeatSubState if (iconP2 != null) iconP2.updatePosition(); } - #if FEATURE_MOBILE_ADVERTISEMENTS - if (Constants.GLOBAL_BLUEBALL_COUNTER > 0 && Constants.GLOBAL_BLUEBALL_COUNTER % 3 == 0) - { - AdMobUtil.loadInterstitial(function():Void { - // Transition to the game over substate. - var gameOverSubState = new GameOverSubState( - { - isChartingMode: isChartingMode, - transparent: persistentDraw - }); - FlxTransitionableState.skipNextTransIn = true; - FlxTransitionableState.skipNextTransOut = true; - openSubState(gameOverSubState); - }); - } - else - { - // Transition to the game over substate. - var gameOverSubState = new GameOverSubState( - { - isChartingMode: isChartingMode, - transparent: persistentDraw - }); - FlxTransitionableState.skipNextTransIn = true; - FlxTransitionableState.skipNextTransOut = true; - openSubState(gameOverSubState); - } - #else // Transition to the game over substate. var gameOverSubState = new GameOverSubState( { @@ -1287,7 +1259,6 @@ class PlayState extends MusicBeatSubState FlxTransitionableState.skipNextTransIn = true; FlxTransitionableState.skipNextTransOut = true; openSubState(gameOverSubState); - #end } function processSongEvents():Void