mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2025-03-20 17:09:21 +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)-->
|
||||
<icon path="art/icon.png"/>
|
||||
<!-- <haxedef name="SKIP_TO_PLAYSTATE" if="debug" /> -->
|
||||
<haxedef name="SKIP_TO_PLAYSTATE" if="debug" />
|
||||
</project>
|
||||
|
|
|
@ -34,20 +34,26 @@ class Alphabet extends FlxSpriteGroup
|
|||
|
||||
var splitWords:Array<String> = [];
|
||||
|
||||
var isBold:Bool = false;
|
||||
|
||||
public function new(x:Float, y:Float, text:String = "", ?bold:Bool = false, typed:Bool = false)
|
||||
{
|
||||
super(x, y);
|
||||
|
||||
_finalText = text;
|
||||
this.text = text;
|
||||
isBold = bold;
|
||||
|
||||
if (typed)
|
||||
if (text != "")
|
||||
{
|
||||
startTypedText();
|
||||
}
|
||||
else
|
||||
{
|
||||
addText();
|
||||
if (typed)
|
||||
{
|
||||
startTypedText();
|
||||
}
|
||||
else
|
||||
{
|
||||
addText();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -71,7 +77,7 @@ class Alphabet extends FlxSpriteGroup
|
|||
var xPos:Float = 0;
|
||||
if (lastSprite != null)
|
||||
{
|
||||
xPos = lastSprite.x + lastSprite.frameWidth;
|
||||
xPos = lastSprite.x + lastSprite.width - 40;
|
||||
}
|
||||
|
||||
if (lastWasSpace)
|
||||
|
@ -82,7 +88,12 @@ class Alphabet extends FlxSpriteGroup
|
|||
|
||||
// var letter:AlphaCharacter = new AlphaCharacter(30 * loopNum, 0);
|
||||
var letter:AlphaCharacter = new AlphaCharacter(xPos, 0);
|
||||
letter.createBold(character);
|
||||
|
||||
if (isBold)
|
||||
letter.createBold(character);
|
||||
else
|
||||
letter.createLetter(character);
|
||||
|
||||
add(letter);
|
||||
|
||||
lastSprite = letter;
|
||||
|
@ -106,10 +117,10 @@ class Alphabet extends FlxSpriteGroup
|
|||
|
||||
var loopNum:Int = 0;
|
||||
|
||||
var xPos:Float = 0;
|
||||
|
||||
new FlxTimer().start(0.05, function(tmr:FlxTimer)
|
||||
{
|
||||
var xPos:Float = 0;
|
||||
|
||||
// trace(_finalText.fastCodeAt(loopNum) + " " + _finalText.charAt(loopNum));
|
||||
if (_finalText.fastCodeAt(loopNum) == "\n".code)
|
||||
{
|
||||
|
@ -118,22 +129,44 @@ class Alphabet extends FlxSpriteGroup
|
|||
// xPos = 0;
|
||||
}
|
||||
|
||||
if (splitWords[loopNum] == " ")
|
||||
{
|
||||
lastWasSpace = true;
|
||||
}
|
||||
|
||||
if (AlphaCharacter.alphabet.contains(splitWords[loopNum].toLowerCase()))
|
||||
{
|
||||
if (lastSprite != null && !xPosResetted)
|
||||
{
|
||||
xPos = lastSprite.x + lastSprite.frameWidth - 40;
|
||||
lastSprite.updateHitbox();
|
||||
xPos += lastSprite.width + 3;
|
||||
// if (isBold)
|
||||
// xPos -= 80;
|
||||
}
|
||||
else
|
||||
{
|
||||
xPosResetted = false;
|
||||
}
|
||||
|
||||
if (lastWasSpace)
|
||||
{
|
||||
xPos += 20;
|
||||
lastWasSpace = false;
|
||||
}
|
||||
// trace(_finalText.fastCodeAt(loopNum) + " " + _finalText.charAt(loopNum));
|
||||
|
||||
// var letter:AlphaCharacter = new AlphaCharacter(30 * loopNum, 0);
|
||||
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);
|
||||
|
||||
lastSprite = letter;
|
||||
|
@ -141,7 +174,7 @@ class Alphabet extends FlxSpriteGroup
|
|||
|
||||
loopNum += 1;
|
||||
|
||||
tmr.time = FlxG.random.float(0.03, 0.09);
|
||||
tmr.time = FlxG.random.float(0.05, 0.12);
|
||||
}, splitWords.length);
|
||||
}
|
||||
|
||||
|
@ -184,5 +217,6 @@ class AlphaCharacter extends FlxSprite
|
|||
|
||||
animation.addByPrefix(letter, letter + " " + letterCase, 24);
|
||||
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 storyPlaylist:Array<String> = [];
|
||||
|
||||
var halloweenLevel:Bool = false;
|
||||
|
||||
private var vocals:FlxSound;
|
||||
|
||||
private var dad:Character;
|
||||
|
@ -71,6 +73,10 @@ class PlayState extends MusicBeatState
|
|||
private var camHUD:FlxCamera;
|
||||
private var camGame:FlxCamera;
|
||||
|
||||
var dialogue:Array<String> = ['blah blah blah', 'coolswag'];
|
||||
|
||||
var halloweenBG:FlxSprite;
|
||||
|
||||
override public function create()
|
||||
{
|
||||
// var gameCam:FlxCamera = FlxG.camera;
|
||||
|
@ -91,28 +97,47 @@ class PlayState extends MusicBeatState
|
|||
|
||||
Conductor.changeBPM(SONG.bpm);
|
||||
|
||||
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);
|
||||
if (SONG.song.toLowerCase() == 'spookeez' || SONG.song.toLowerCase() == 'monster' || SONG.song.toLowerCase() == 'south')
|
||||
{
|
||||
halloweenLevel = true;
|
||||
|
||||
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 hallowTex = FlxAtlasFrames.fromSparrow(AssetPaths.halloween_bg__png, AssetPaths.halloween_bg__xml);
|
||||
|
||||
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;
|
||||
halloweenBG = new FlxSprite(-200, -100);
|
||||
halloweenBG.frames = hallowTex;
|
||||
halloweenBG.animation.addByPrefix('idle', 'halloweem bg0');
|
||||
halloweenBG.animation.addByPrefix('lightning', 'halloweem bg lightning strike', 24, false);
|
||||
halloweenBG.animation.play('idle');
|
||||
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.scrollFactor.set(0.95, 0.95);
|
||||
|
@ -136,7 +161,14 @@ class PlayState extends MusicBeatState
|
|||
boyfriend = new Boyfriend(770, 450);
|
||||
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.scrollFactor.set();
|
||||
|
@ -148,7 +180,7 @@ class PlayState extends MusicBeatState
|
|||
|
||||
startingSong = true;
|
||||
|
||||
startCountdown();
|
||||
// startCountdown();
|
||||
|
||||
generateSong(SONG.song);
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class TitleState extends MusicBeatState
|
|||
super.create();
|
||||
|
||||
#if SKIP_TO_PLAYSTATE
|
||||
FlxG.switchState(new MainMenuState());
|
||||
FlxG.switchState(new PlayState());
|
||||
#else
|
||||
startIntro();
|
||||
#end
|
||||
|
|
Loading…
Reference in a new issue