mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-04 22:04:29 +00:00
sound effects for stickersubstate
This commit is contained in:
parent
6e2441b540
commit
0c0829b2d0
2
assets
2
assets
|
@ -1 +1 @@
|
||||||
Subproject commit d946072ac531e049e2a817048b65fa1ca541134a
|
Subproject commit 775a0c0a5b2d3009fbec17560c7364a4ac61e3c7
|
|
@ -17,6 +17,9 @@ import openfl.geom.Matrix;
|
||||||
import openfl.display.Sprite;
|
import openfl.display.Sprite;
|
||||||
import openfl.display.Bitmap;
|
import openfl.display.Bitmap;
|
||||||
|
|
||||||
|
using Lambda;
|
||||||
|
using StringTools;
|
||||||
|
|
||||||
class StickerSubState extends MusicBeatSubState
|
class StickerSubState extends MusicBeatSubState
|
||||||
{
|
{
|
||||||
public var grpStickers:FlxTypedGroup<StickerSprite>;
|
public var grpStickers:FlxTypedGroup<StickerSprite>;
|
||||||
|
@ -26,10 +29,60 @@ class StickerSubState extends MusicBeatSubState
|
||||||
|
|
||||||
var nextState:NEXTSTATE = FREEPLAY;
|
var nextState:NEXTSTATE = FREEPLAY;
|
||||||
|
|
||||||
|
// what "folders" to potentially load from (as of writing only "keys" exist)
|
||||||
|
var soundSelections:Array<String> = [];
|
||||||
|
// what "folder" was randomly selected
|
||||||
|
var soundSelection:String = "";
|
||||||
|
var sounds:Array<String> = [];
|
||||||
|
|
||||||
public function new(?oldStickers:Array<StickerSprite>, ?nextState:NEXTSTATE = FREEPLAY):Void
|
public function new(?oldStickers:Array<StickerSprite>, ?nextState:NEXTSTATE = FREEPLAY):Void
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
// todo still
|
||||||
|
// make sure that ONLY plays mp3/ogg files
|
||||||
|
// if there's no mp3/ogg file, then it regenerates/reloads the random folder
|
||||||
|
|
||||||
|
var assetsInList = openfl.utils.Assets.list();
|
||||||
|
|
||||||
|
var soundFilterFunc = function(a:String) {
|
||||||
|
return a.startsWith('assets/shared/sounds/stickersounds/');
|
||||||
|
};
|
||||||
|
|
||||||
|
soundSelections = assetsInList.filter(soundFilterFunc);
|
||||||
|
soundSelections = soundSelections.map(function(a:String) {
|
||||||
|
return a.replace('assets/shared/sounds/stickersounds/', '').split('/')[0];
|
||||||
|
});
|
||||||
|
|
||||||
|
// cracked cleanup... yuchh...
|
||||||
|
for (i in soundSelections)
|
||||||
|
{
|
||||||
|
while (soundSelections.contains(i))
|
||||||
|
{
|
||||||
|
soundSelections.remove(i);
|
||||||
|
}
|
||||||
|
soundSelections.push(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
trace(soundSelections);
|
||||||
|
|
||||||
|
soundSelection = FlxG.random.getObject(soundSelections);
|
||||||
|
|
||||||
|
var filterFunc = function(a:String) {
|
||||||
|
return a.startsWith('assets/shared/sounds/stickersounds/' + soundSelection + '/');
|
||||||
|
};
|
||||||
|
var assetsInList3 = openfl.utils.Assets.list();
|
||||||
|
sounds = assetsInList3.filter(filterFunc);
|
||||||
|
for (i in 0...sounds.length)
|
||||||
|
{
|
||||||
|
sounds[i] = sounds[i].replace('assets/shared/sounds/', '');
|
||||||
|
sounds[i] = sounds[i].substring(0, sounds[i].lastIndexOf('.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
trace(sounds);
|
||||||
|
|
||||||
|
// trace(assetsInList);
|
||||||
|
|
||||||
this.nextState = nextState;
|
this.nextState = nextState;
|
||||||
|
|
||||||
grpStickers = new FlxTypedGroup<StickerSprite>();
|
grpStickers = new FlxTypedGroup<StickerSprite>();
|
||||||
|
@ -66,6 +119,8 @@ class StickerSubState extends MusicBeatSubState
|
||||||
{
|
{
|
||||||
new FlxTimer().start(sticker.timing, _ -> {
|
new FlxTimer().start(sticker.timing, _ -> {
|
||||||
sticker.visible = false;
|
sticker.visible = false;
|
||||||
|
var daSound:String = FlxG.random.getObject(sounds);
|
||||||
|
FlxG.sound.play(Paths.sound(daSound));
|
||||||
|
|
||||||
if (ind == grpStickers.members.length - 1)
|
if (ind == grpStickers.members.length - 1)
|
||||||
{
|
{
|
||||||
|
@ -152,6 +207,8 @@ class StickerSubState extends MusicBeatSubState
|
||||||
|
|
||||||
new FlxTimer().start(sticker.timing, _ -> {
|
new FlxTimer().start(sticker.timing, _ -> {
|
||||||
sticker.visible = true;
|
sticker.visible = true;
|
||||||
|
var daSound:String = FlxG.random.getObject(sounds);
|
||||||
|
FlxG.sound.play(Paths.sound(daSound));
|
||||||
|
|
||||||
var frameTimer:Int = FlxG.random.int(0, 2);
|
var frameTimer:Int = FlxG.random.int(0, 2);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue