mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-03-24 10:59:32 +00:00
ALMOST DIALOGUE
This commit is contained in:
parent
0fcd92f6d9
commit
81496c4f5d
|
@ -94,5 +94,5 @@
|
||||||
|
|
||||||
<!--Place custom nodes like icons here (higher priority to override the HaxeFlixel icon)-->
|
<!--Place custom nodes like icons here (higher priority to override the HaxeFlixel icon)-->
|
||||||
<icon path="art/icon.png"/>
|
<icon path="art/icon.png"/>
|
||||||
<!-- <haxedef name="SKIP_TO_PLAYSTATE" if="debug" /> -->
|
<haxedef name="SKIP_TO_PLAYSTATE" if="debug" />
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -34,20 +34,26 @@ class Alphabet extends FlxSpriteGroup
|
||||||
|
|
||||||
var splitWords:Array<String> = [];
|
var splitWords:Array<String> = [];
|
||||||
|
|
||||||
|
var isBold:Bool = false;
|
||||||
|
|
||||||
public function new(x:Float, y:Float, text:String = "", ?bold:Bool = false, typed:Bool = false)
|
public function new(x:Float, y:Float, text:String = "", ?bold:Bool = false, typed:Bool = false)
|
||||||
{
|
{
|
||||||
super(x, y);
|
super(x, y);
|
||||||
|
|
||||||
_finalText = text;
|
_finalText = text;
|
||||||
this.text = text;
|
this.text = text;
|
||||||
|
isBold = bold;
|
||||||
|
|
||||||
if (typed)
|
if (text != "")
|
||||||
{
|
{
|
||||||
startTypedText();
|
if (typed)
|
||||||
}
|
{
|
||||||
else
|
startTypedText();
|
||||||
{
|
}
|
||||||
addText();
|
else
|
||||||
|
{
|
||||||
|
addText();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +77,7 @@ class Alphabet extends FlxSpriteGroup
|
||||||
var xPos:Float = 0;
|
var xPos:Float = 0;
|
||||||
if (lastSprite != null)
|
if (lastSprite != null)
|
||||||
{
|
{
|
||||||
xPos = lastSprite.x + lastSprite.frameWidth;
|
xPos = lastSprite.x + lastSprite.width - 40;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastWasSpace)
|
if (lastWasSpace)
|
||||||
|
@ -82,7 +88,12 @@ class Alphabet extends FlxSpriteGroup
|
||||||
|
|
||||||
// var letter:AlphaCharacter = new AlphaCharacter(30 * loopNum, 0);
|
// var letter:AlphaCharacter = new AlphaCharacter(30 * loopNum, 0);
|
||||||
var letter:AlphaCharacter = new AlphaCharacter(xPos, 0);
|
var letter:AlphaCharacter = new AlphaCharacter(xPos, 0);
|
||||||
letter.createBold(character);
|
|
||||||
|
if (isBold)
|
||||||
|
letter.createBold(character);
|
||||||
|
else
|
||||||
|
letter.createLetter(character);
|
||||||
|
|
||||||
add(letter);
|
add(letter);
|
||||||
|
|
||||||
lastSprite = letter;
|
lastSprite = letter;
|
||||||
|
@ -106,10 +117,10 @@ class Alphabet extends FlxSpriteGroup
|
||||||
|
|
||||||
var loopNum:Int = 0;
|
var loopNum:Int = 0;
|
||||||
|
|
||||||
|
var xPos:Float = 0;
|
||||||
|
|
||||||
new FlxTimer().start(0.05, function(tmr:FlxTimer)
|
new FlxTimer().start(0.05, function(tmr:FlxTimer)
|
||||||
{
|
{
|
||||||
var xPos:Float = 0;
|
|
||||||
|
|
||||||
// trace(_finalText.fastCodeAt(loopNum) + " " + _finalText.charAt(loopNum));
|
// trace(_finalText.fastCodeAt(loopNum) + " " + _finalText.charAt(loopNum));
|
||||||
if (_finalText.fastCodeAt(loopNum) == "\n".code)
|
if (_finalText.fastCodeAt(loopNum) == "\n".code)
|
||||||
{
|
{
|
||||||
|
@ -118,22 +129,44 @@ class Alphabet extends FlxSpriteGroup
|
||||||
// xPos = 0;
|
// xPos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (splitWords[loopNum] == " ")
|
||||||
|
{
|
||||||
|
lastWasSpace = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (AlphaCharacter.alphabet.contains(splitWords[loopNum].toLowerCase()))
|
if (AlphaCharacter.alphabet.contains(splitWords[loopNum].toLowerCase()))
|
||||||
{
|
{
|
||||||
if (lastSprite != null && !xPosResetted)
|
if (lastSprite != null && !xPosResetted)
|
||||||
{
|
{
|
||||||
xPos = lastSprite.x + lastSprite.frameWidth - 40;
|
lastSprite.updateHitbox();
|
||||||
|
xPos += lastSprite.width + 3;
|
||||||
|
// if (isBold)
|
||||||
|
// xPos -= 80;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
xPosResetted = false;
|
xPosResetted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lastWasSpace)
|
||||||
|
{
|
||||||
|
xPos += 20;
|
||||||
|
lastWasSpace = false;
|
||||||
|
}
|
||||||
// trace(_finalText.fastCodeAt(loopNum) + " " + _finalText.charAt(loopNum));
|
// trace(_finalText.fastCodeAt(loopNum) + " " + _finalText.charAt(loopNum));
|
||||||
|
|
||||||
// var letter:AlphaCharacter = new AlphaCharacter(30 * loopNum, 0);
|
// var letter:AlphaCharacter = new AlphaCharacter(30 * loopNum, 0);
|
||||||
var letter:AlphaCharacter = new AlphaCharacter(xPos, 55 * yMulti);
|
var letter:AlphaCharacter = new AlphaCharacter(xPos, 55 * yMulti);
|
||||||
letter.createBold(splitWords[loopNum]);
|
if (isBold)
|
||||||
|
{
|
||||||
|
letter.createBold(splitWords[loopNum]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
letter.createLetter(splitWords[loopNum]);
|
||||||
|
letter.x += 90;
|
||||||
|
}
|
||||||
|
|
||||||
add(letter);
|
add(letter);
|
||||||
|
|
||||||
lastSprite = letter;
|
lastSprite = letter;
|
||||||
|
@ -141,7 +174,7 @@ class Alphabet extends FlxSpriteGroup
|
||||||
|
|
||||||
loopNum += 1;
|
loopNum += 1;
|
||||||
|
|
||||||
tmr.time = FlxG.random.float(0.03, 0.09);
|
tmr.time = FlxG.random.float(0.05, 0.12);
|
||||||
}, splitWords.length);
|
}, splitWords.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,5 +217,6 @@ class AlphaCharacter extends FlxSprite
|
||||||
|
|
||||||
animation.addByPrefix(letter, letter + " " + letterCase, 24);
|
animation.addByPrefix(letter, letter + " " + letterCase, 24);
|
||||||
animation.play(letter);
|
animation.play(letter);
|
||||||
|
updateHitbox();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
86
source/DialogueBox.hx
Normal file
86
source/DialogueBox.hx
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
package;
|
||||||
|
|
||||||
|
import flixel.FlxG;
|
||||||
|
import flixel.FlxSprite;
|
||||||
|
import flixel.graphics.frames.FlxAtlasFrames;
|
||||||
|
import flixel.group.FlxSpriteGroup;
|
||||||
|
import flixel.input.FlxKeyManager;
|
||||||
|
|
||||||
|
class DialogueBox extends FlxSpriteGroup
|
||||||
|
{
|
||||||
|
var box:FlxSprite;
|
||||||
|
|
||||||
|
var dialogue:Alphabet;
|
||||||
|
var dialogueList:Array<String> = [];
|
||||||
|
|
||||||
|
public var finishThing:Void->Void;
|
||||||
|
|
||||||
|
public function new(talkingRight:Bool = true, ?dialogueList:Array<String>)
|
||||||
|
{
|
||||||
|
super();
|
||||||
|
|
||||||
|
box = new FlxSprite(40);
|
||||||
|
box.frames = FlxAtlasFrames.fromSparrow(AssetPaths.speech_bubble_talking__png, AssetPaths.speech_bubble_talking__xml);
|
||||||
|
box.animation.addByPrefix('normalOpen', 'Speech Bubble Normal Open', 24, false);
|
||||||
|
box.animation.addByPrefix('normal', 'speech bubble normal', 24);
|
||||||
|
box.animation.play('normalOpen');
|
||||||
|
add(box);
|
||||||
|
|
||||||
|
if (!talkingRight)
|
||||||
|
{
|
||||||
|
box.flipX = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
dialogue = new Alphabet(0, 80, "", false, true);
|
||||||
|
// dialogue.x = 90;
|
||||||
|
add(dialogue);
|
||||||
|
|
||||||
|
this.dialogueList = dialogueList;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dialogueOpened:Bool = false;
|
||||||
|
var dialogueStarted:Bool = false;
|
||||||
|
|
||||||
|
override function update(elapsed:Float)
|
||||||
|
{
|
||||||
|
if (box.animation.curAnim != null)
|
||||||
|
{
|
||||||
|
if (box.animation.curAnim.name == 'normalOpen' && box.animation.curAnim.finished)
|
||||||
|
{
|
||||||
|
box.animation.play('normal');
|
||||||
|
dialogueOpened = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dialogueOpened && !dialogueStarted)
|
||||||
|
{
|
||||||
|
startDialogue();
|
||||||
|
dialogueStarted = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FlxG.keys.justPressed.SPACE)
|
||||||
|
{
|
||||||
|
remove(dialogue);
|
||||||
|
|
||||||
|
if (dialogueList[1] == null)
|
||||||
|
{
|
||||||
|
finishThing();
|
||||||
|
kill();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dialogueList.remove(dialogueList[0]);
|
||||||
|
startDialogue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.update(elapsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
function startDialogue():Void
|
||||||
|
{
|
||||||
|
var theDialog:Alphabet = new Alphabet(0, 70, dialogueList[0], false, true);
|
||||||
|
dialogue = theDialog;
|
||||||
|
add(theDialog);
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,6 +38,8 @@ class PlayState extends MusicBeatState
|
||||||
public static var isStoryMode:Bool = false;
|
public static var isStoryMode:Bool = false;
|
||||||
public static var storyPlaylist:Array<String> = [];
|
public static var storyPlaylist:Array<String> = [];
|
||||||
|
|
||||||
|
var halloweenLevel:Bool = false;
|
||||||
|
|
||||||
private var vocals:FlxSound;
|
private var vocals:FlxSound;
|
||||||
|
|
||||||
private var dad:Character;
|
private var dad:Character;
|
||||||
|
@ -71,6 +73,10 @@ class PlayState extends MusicBeatState
|
||||||
private var camHUD:FlxCamera;
|
private var camHUD:FlxCamera;
|
||||||
private var camGame:FlxCamera;
|
private var camGame:FlxCamera;
|
||||||
|
|
||||||
|
var dialogue:Array<String> = ['blah blah blah', 'coolswag'];
|
||||||
|
|
||||||
|
var halloweenBG:FlxSprite;
|
||||||
|
|
||||||
override public function create()
|
override public function create()
|
||||||
{
|
{
|
||||||
// var gameCam:FlxCamera = FlxG.camera;
|
// var gameCam:FlxCamera = FlxG.camera;
|
||||||
|
@ -91,28 +97,47 @@ class PlayState extends MusicBeatState
|
||||||
|
|
||||||
Conductor.changeBPM(SONG.bpm);
|
Conductor.changeBPM(SONG.bpm);
|
||||||
|
|
||||||
var bg:FlxSprite = new FlxSprite(-600, -200).loadGraphic(AssetPaths.stageback__png);
|
if (SONG.song.toLowerCase() == 'spookeez' || SONG.song.toLowerCase() == 'monster' || SONG.song.toLowerCase() == 'south')
|
||||||
// bg.setGraphicSize(Std.int(bg.width * 2.5));
|
{
|
||||||
// bg.updateHitbox();
|
halloweenLevel = true;
|
||||||
bg.antialiasing = true;
|
|
||||||
bg.scrollFactor.set(0.9, 0.9);
|
|
||||||
bg.active = false;
|
|
||||||
add(bg);
|
|
||||||
|
|
||||||
var stageFront:FlxSprite = new FlxSprite(-650, 600).loadGraphic(AssetPaths.stagefront__png);
|
var hallowTex = FlxAtlasFrames.fromSparrow(AssetPaths.halloween_bg__png, AssetPaths.halloween_bg__xml);
|
||||||
stageFront.setGraphicSize(Std.int(stageFront.width * 1.1));
|
|
||||||
stageFront.updateHitbox();
|
|
||||||
stageFront.antialiasing = true;
|
|
||||||
stageFront.scrollFactor.set(0.9, 0.9);
|
|
||||||
stageFront.active = false;
|
|
||||||
add(stageFront);
|
|
||||||
|
|
||||||
var stageCurtains:FlxSprite = new FlxSprite(-500, -300).loadGraphic(AssetPaths.stagecurtains__png);
|
halloweenBG = new FlxSprite(-200, -100);
|
||||||
stageCurtains.setGraphicSize(Std.int(stageCurtains.width * 0.9));
|
halloweenBG.frames = hallowTex;
|
||||||
stageCurtains.updateHitbox();
|
halloweenBG.animation.addByPrefix('idle', 'halloweem bg0');
|
||||||
stageCurtains.antialiasing = true;
|
halloweenBG.animation.addByPrefix('lightning', 'halloweem bg lightning strike', 24, false);
|
||||||
stageCurtains.scrollFactor.set(1.3, 1.3);
|
halloweenBG.animation.play('idle');
|
||||||
stageCurtains.active = false;
|
halloweenBG.antialiasing = true;
|
||||||
|
add(halloweenBG);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var bg:FlxSprite = new FlxSprite(-600, -200).loadGraphic(AssetPaths.stageback__png);
|
||||||
|
// bg.setGraphicSize(Std.int(bg.width * 2.5));
|
||||||
|
// bg.updateHitbox();
|
||||||
|
bg.antialiasing = true;
|
||||||
|
bg.scrollFactor.set(0.9, 0.9);
|
||||||
|
bg.active = false;
|
||||||
|
add(bg);
|
||||||
|
|
||||||
|
var stageFront:FlxSprite = new FlxSprite(-650, 600).loadGraphic(AssetPaths.stagefront__png);
|
||||||
|
stageFront.setGraphicSize(Std.int(stageFront.width * 1.1));
|
||||||
|
stageFront.updateHitbox();
|
||||||
|
stageFront.antialiasing = true;
|
||||||
|
stageFront.scrollFactor.set(0.9, 0.9);
|
||||||
|
stageFront.active = false;
|
||||||
|
add(stageFront);
|
||||||
|
|
||||||
|
var stageCurtains:FlxSprite = new FlxSprite(-500, -300).loadGraphic(AssetPaths.stagecurtains__png);
|
||||||
|
stageCurtains.setGraphicSize(Std.int(stageCurtains.width * 0.9));
|
||||||
|
stageCurtains.updateHitbox();
|
||||||
|
stageCurtains.antialiasing = true;
|
||||||
|
stageCurtains.scrollFactor.set(1.3, 1.3);
|
||||||
|
stageCurtains.active = false;
|
||||||
|
|
||||||
|
add(stageCurtains);
|
||||||
|
}
|
||||||
|
|
||||||
gf = new Character(400, 130, 'gf');
|
gf = new Character(400, 130, 'gf');
|
||||||
gf.scrollFactor.set(0.95, 0.95);
|
gf.scrollFactor.set(0.95, 0.95);
|
||||||
|
@ -136,7 +161,14 @@ class PlayState extends MusicBeatState
|
||||||
boyfriend = new Boyfriend(770, 450);
|
boyfriend = new Boyfriend(770, 450);
|
||||||
add(boyfriend);
|
add(boyfriend);
|
||||||
|
|
||||||
add(stageCurtains);
|
var doof:DialogueBox = new DialogueBox(false, dialogue);
|
||||||
|
// doof.x += 70;
|
||||||
|
doof.y = FlxG.height * 0.5;
|
||||||
|
doof.scrollFactor.set();
|
||||||
|
doof.finishThing = startCountdown;
|
||||||
|
add(doof);
|
||||||
|
|
||||||
|
Conductor.songPosition = -5000;
|
||||||
|
|
||||||
strumLine = new FlxSprite(0, 50).makeGraphic(FlxG.width, 10);
|
strumLine = new FlxSprite(0, 50).makeGraphic(FlxG.width, 10);
|
||||||
strumLine.scrollFactor.set();
|
strumLine.scrollFactor.set();
|
||||||
|
@ -148,7 +180,7 @@ class PlayState extends MusicBeatState
|
||||||
|
|
||||||
startingSong = true;
|
startingSong = true;
|
||||||
|
|
||||||
startCountdown();
|
// startCountdown();
|
||||||
|
|
||||||
generateSong(SONG.song);
|
generateSong(SONG.song);
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ class TitleState extends MusicBeatState
|
||||||
super.create();
|
super.create();
|
||||||
|
|
||||||
#if SKIP_TO_PLAYSTATE
|
#if SKIP_TO_PLAYSTATE
|
||||||
FlxG.switchState(new MainMenuState());
|
FlxG.switchState(new PlayState());
|
||||||
#else
|
#else
|
||||||
startIntro();
|
startIntro();
|
||||||
#end
|
#end
|
||||||
|
|
Loading…
Reference in a new issue