Skip to content

Commit

Permalink
use _bgSprite instead
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed May 12, 2024
1 parent e6e6af6 commit 2bdc5b3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 36 deletions.
1 change: 1 addition & 0 deletions example_mods/TemplateScript.hx
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ getPref(prefName:String);
'antialiasing' => Antialiasing
'quality' => Image LOD Quality ("high", "medium", "low", "rudy")
'gpu-textures' => Use GPU Textures Caching
'song-stream' => Use OGG Songs Streaming
'preload' => Preload Assets At Start
// Miscellaneous
Expand Down
12 changes: 8 additions & 4 deletions source/funkin/substates/MusicBeatSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ import flixel.FlxSubState;
class MusicBeatSubstate extends FlxSubState implements IMusicGetter
{
public var musicBeat(default, null):MusicBeat;
public function new(createMusic:Bool = true) {
super();
if (createMusic)
add(musicBeat = new MusicBeat(this));

public function new(createMusic:Bool = true, ?bgColor:FlxColor)
{
super(bgColor);
_bgSprite.active = false;
_bgSprite.scrollFactor.set();
if (bgColor == null) _bgSprite.visible = false; // Wont need to render this guy
if (createMusic) add(musicBeat = new MusicBeat(this));
}

public var _update:Dynamic = null;
Expand Down
16 changes: 6 additions & 10 deletions source/funkin/substates/NotesSubstate.hx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,18 @@ package funkin.substates;

import funkin.objects.NotesGroup;

class NotesSubstate extends MusicBeatSubstate {
class NotesSubstate extends MusicBeatSubstate
{
public var SONG:SwagSong;
public var notesGroup:NotesGroup;
public var position:Float = 0;

public function new(_SONG:SwagSong, position:Float) {
super();
public function new(song:SwagSong, position:Float)
{
super(true, 0x98000000);
this.position = position;

final bg:FlxSprite = new FlxSprite().makeGraphic(FlxG.width, FlxG.height, FlxColor.BLACK);
bg.alpha = 0.6;
bg.scrollFactor.set();
bg.antialiasing = false;
add(bg);

SONG = Song.checkSong(_SONG);
SONG = Song.checkSong(song);
notesGroup = new NotesGroup(SONG, false);
notesGroup.skipStrumIntro = true;
notesGroup.init(position - 50);
Expand Down
22 changes: 8 additions & 14 deletions source/funkin/substates/PauseSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class PauseSubState extends MusicBeatSubstate {
'Options',
'Exit to menu'
];
var bg:FlxSprite;
var timeLeft:FunkinText;

var pauseMusic:FlxSound;
Expand All @@ -22,20 +21,13 @@ class PauseSubState extends MusicBeatSubstate {

var maxTime:String = "";

public function new():Void {
super(false);
public function new():Void
{
super(false, 0x98000000);
pauseMusic = CoolUtil.getSound("breakfast", MUSIC);
pauseMusic.looped = true;
pauseLength = Std.int(pauseMusic.length * 0.5);

bg = new FlxSprite().makeGraphic(1, 1, FlxColor.BLACK);
bg.scrollFactor.set();
bg.antialiasing = false;
bg.scale.set(FlxG.width, FlxG.height);
bg.updateHitbox();
bg.active = false;
add(bg);

final levelInfo:FunkinText = new FunkinText(20,15,PlayState.SONG.song,32);
final levelDifficulty:FunkinText = new FunkinText(20,15,(PlayState.curDifficulty.toUpperCase()),32);
final deathCounter:FunkinText = new FunkinText(20,15,"Blue balled: " + PlayState.deathCounter,32);
Expand Down Expand Up @@ -72,8 +64,8 @@ class PauseSubState extends MusicBeatSubstate {
timeLeft.text = "Time left: " + curTime + " / " + maxTime;
timeLeft.x = FlxG.width - (timeLeft.width + 20);

bg.alpha = 0.00001;
FlxTween.tween(bg, {alpha: 0.6}, 0.4, {ease: FlxEase.quartInOut});
_bgSprite.alpha = 0.00001;
FlxTween.tween(_bgSprite, {alpha: 1}, 0.4, {ease: FlxEase.quartInOut});

for (i in 0...items.length) {
items[i].setPosition(-100 * i, (70 * i) + 200);
Expand All @@ -82,7 +74,9 @@ class PauseSubState extends MusicBeatSubstate {
coolDown = 0.1;
curSelected = 0;
changeSelection();
cameras = [CoolUtil.getTopCam()];

camera = CoolUtil.getTopCam();
_bgSprite.camera = camera;
}

var coolDown:Float = 0.1; //Controllers have a lil lag
Expand Down
15 changes: 7 additions & 8 deletions source/funkin/substates/PromptSubstate.hx
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
package funkin.substates;

class PromptSubstate extends MusicBeatSubstate {
class PromptSubstate extends MusicBeatSubstate
{
var acceptFunction:()->Void;
var acceptRequirement:()->Bool;

public function new(text:String, ?acceptFunction:()->Void, ?acceptRequirement:()->Bool, textScale:Float = 0.75) {
super();
public function new(text:String, ?acceptFunction:()->Void, ?acceptRequirement:()->Bool, textScale:Float = 0.75)
{
super(false, 0x98000000);
this.acceptFunction = acceptFunction;
this.acceptRequirement = acceptRequirement;

var bg = new FlxSpriteExt().makeRect(FlxG.width, FlxG.height, FlxColor.BLACK);
bg.alpha = 0.6;
add(bg);

var prompBox = new FlxSpriteExt().makeRect(1200, 500, 0xFFFAFD6D);
prompBox.scrollFactor.set();
prompBox.screenCenter();
add(prompBox);

var prompText:Alphabet = new Alphabet(0, prompBox.y + 75, text);
prompText.scrollFactor.set();
prompText.scale.scale(textScale, textScale);
prompText.alignment = CENTER;
prompText.screenCenter(X);
add(prompText);

camera = CoolUtil.getTopCam();
for (i in [bg,prompBox,prompText]) i.scrollFactor.set();
}

var startTimer:Float = 0.15;
Expand Down

0 comments on commit 2bdc5b3

Please sign in to comment.