mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-14 19:25:16 -05:00
cartoons and stuff
This commit is contained in:
parent
546e15dcac
commit
ba896508cc
3 changed files with 76 additions and 6 deletions
2
assets
2
assets
|
@ -1 +1 @@
|
|||
Subproject commit 096b42fb7d263752cd39ab76ef0cc1bcb391ea51
|
||||
Subproject commit 386dcac52e7b8ddc8cc4ad3864bd8d51f01564d1
|
49
source/funkin/audio/FlxStreamSound.hx
Normal file
49
source/funkin/audio/FlxStreamSound.hx
Normal file
|
@ -0,0 +1,49 @@
|
|||
package funkin.audio;
|
||||
|
||||
import flash.media.Sound;
|
||||
#if flash11
|
||||
import flash.utils.ByteArray;
|
||||
#end
|
||||
import flixel.sound.FlxSound;
|
||||
import flixel.system.FlxAssets.FlxSoundAsset;
|
||||
import openfl.Assets;
|
||||
#if (openfl >= "8.0.0")
|
||||
import openfl.utils.AssetType;
|
||||
#end
|
||||
|
||||
/**
|
||||
* a FlxSound that just overrides loadEmbedded to allow for "streamed" sounds to load with better performance!
|
||||
*/
|
||||
class FlxStreamSound extends FlxSound
|
||||
{
|
||||
public function new()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
override public function loadEmbedded(EmbeddedSound:FlxSoundAsset, Looped:Bool = false, AutoDestroy:Bool = false, ?OnComplete:Void->Void):FlxSound
|
||||
{
|
||||
if (EmbeddedSound == null) return this;
|
||||
|
||||
cleanup(true);
|
||||
|
||||
if ((EmbeddedSound is Sound))
|
||||
{
|
||||
_sound = EmbeddedSound;
|
||||
}
|
||||
else if ((EmbeddedSound is Class))
|
||||
{
|
||||
_sound = Type.createInstance(EmbeddedSound, []);
|
||||
}
|
||||
else if ((EmbeddedSound is String))
|
||||
{
|
||||
if (Assets.exists(EmbeddedSound, AssetType.SOUND)
|
||||
|| Assets.exists(EmbeddedSound, AssetType.MUSIC)) _sound = Assets.getMusic(EmbeddedSound);
|
||||
else
|
||||
FlxG.log.error('Could not find a Sound asset with an ID of \'$EmbeddedSound\'.');
|
||||
}
|
||||
|
||||
// NOTE: can't pull ID3 info from embedded sound currently
|
||||
return init(Looped, AutoDestroy, OnComplete);
|
||||
}
|
||||
}
|
|
@ -5,6 +5,8 @@ import flixel.util.FlxSignal;
|
|||
import funkin.util.assets.FlxAnimationUtil;
|
||||
import funkin.graphics.adobeanimate.FlxAtlasSprite;
|
||||
import flixel.system.FlxSound;
|
||||
import flixel.util.FlxTimer;
|
||||
import funkin.audio.FlxStreamSound;
|
||||
|
||||
class DJBoyfriend extends FlxAtlasSprite
|
||||
{
|
||||
|
@ -169,7 +171,7 @@ class DJBoyfriend extends FlxAtlasSprite
|
|||
addOffset('bf dj afk', 0, 0);
|
||||
}
|
||||
|
||||
var cartoonSnd:FlxSound;
|
||||
var cartoonSnd:FlxStreamSound;
|
||||
|
||||
public var playingCartoon:Bool = false;
|
||||
|
||||
|
@ -180,21 +182,40 @@ class DJBoyfriend extends FlxAtlasSprite
|
|||
// tv is OFF, but getting turned on
|
||||
FlxG.sound.play(Paths.sound('tv_on'));
|
||||
|
||||
cartoonSnd = new FlxSound();
|
||||
cartoonSnd = new FlxStreamSound();
|
||||
FlxG.sound.defaultSoundGroup.add(cartoonSnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
// plays it smidge after the click
|
||||
new FlxTimer().start(0.5, 1, function(_) {
|
||||
new FlxTimer().start(0.1, function(_) {
|
||||
FlxG.sound.play(Paths.sound('channel_switch'));
|
||||
});
|
||||
}
|
||||
// cartoonSnd.loadEmbedded(Paths.sound("cartoons/peck"));
|
||||
// cartoonSnd.play();
|
||||
|
||||
// play sound of random flash toon
|
||||
// if tv is already playing, play a new one
|
||||
loadCartoon();
|
||||
}
|
||||
|
||||
function loadCartoon()
|
||||
{
|
||||
cartoonSnd.loadEmbedded(Paths.sound(getRandomFlashToon()), false, false, function() {
|
||||
anim.play("Boyfriend DJ watchin tv OG", true, false, 60);
|
||||
});
|
||||
cartoonSnd.play(true, FlxG.random.float(0, cartoonSnd.length));
|
||||
}
|
||||
|
||||
var cartoonList:Array<String> = Assets.list().filter(function(path) return path.startsWith("assets/sounds/cartoons/"));
|
||||
|
||||
function getRandomFlashToon():String
|
||||
{
|
||||
var randomFile = FlxG.random.getObject(cartoonList);
|
||||
|
||||
randomFile = randomFile.replace("assets/sounds/", "");
|
||||
randomFile = randomFile.substring(0, randomFile.length - 4);
|
||||
|
||||
return randomFile;
|
||||
}
|
||||
|
||||
public function confirm():Void
|
||||
|
|
Loading…
Reference in a new issue