goofy ahh dialog
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
<!DOCTYPE codename-engine-dialogue-box>
|
||||
<dialoguebox scale="0.9" y="100">
|
||||
<dialoguebox scale="0.9" y="75">
|
||||
<!-- All positions for the dialogue box -->
|
||||
<charpos name="left" x="-500" y="0" />
|
||||
<charpos name="middle" x="0" y="0" />
|
||||
<charpos name="right" x="500" y="0" flipBubble="true" />
|
||||
<charpos name="left" x="-500" y="184" />
|
||||
<charpos name="middle" x="0" y="184" />
|
||||
<charpos name="right" x="500" y="184" flipBubble="true" />
|
||||
|
||||
<!--
|
||||
All animations for the dialogue box
|
||||
For example, if you wanna add an "angry" animation, add an animation named "angry" (box idle), and "angry-open" (not needed, for box apparition)
|
||||
-->
|
||||
<anim name="normal" anim="speech bubble normal" fps="24" loop="true"/>
|
||||
<anim name="normal" anim="speech bubble normal" fps="24" loop="true" x="-30"/>
|
||||
<anim name="normal-open" anim="Speech Bubble Normal Open" fps="24" />
|
||||
|
||||
<anim name="angry" anim="AHH speech bubble" fps="24" loop="true"/>
|
||||
<anim name="angry-open" anim="speech bubble loud open" fps="24" />
|
||||
<anim name="angry" anim="AHH speech bubble" fps="24" loop="true" y="60"/>
|
||||
<anim name="angry-open" anim="speech bubble loud open" fps="24" y="60"/>
|
||||
</dialoguebox>
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE codename-engine-dialogue-character>
|
||||
<character>
|
||||
<character x="285">
|
||||
<anim name="normal" anim="normal" fps="24" />
|
||||
</character>
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE codename-engine-dialogue-character>
|
||||
<character>
|
||||
<character x="50" y="-60">
|
||||
<anim name="normal" anim="normal" fps="24" />
|
||||
</character>
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE codename-engine-dialogue-character>
|
||||
<character>
|
||||
<character x="250" y="-350">
|
||||
<anim name="normal" anim="normal" fps="24" />
|
||||
</character>
|
||||
+1
-1
@@ -1 +1 @@
|
||||
2112
|
||||
2122
|
||||
@@ -18,13 +18,14 @@ class DialogueCutscene extends Cutscene {
|
||||
public var dialogueBox:DialogueBox;
|
||||
|
||||
public var nextSFX:FlxSound;
|
||||
public var dialogueCamera:FlxCamera;
|
||||
|
||||
public function new(dialoguePath:String, callback:Void->Void) {
|
||||
super(callback);
|
||||
this.dialoguePath = dialoguePath;
|
||||
camera = new FlxCamera();
|
||||
camera.bgColor = 0;
|
||||
FlxG.cameras.add(camera, false);
|
||||
camera = dialogueCamera = new FlxCamera();
|
||||
dialogueCamera.bgColor = 0;
|
||||
FlxG.cameras.add(dialogueCamera, false);
|
||||
}
|
||||
|
||||
public override function create() {
|
||||
@@ -56,6 +57,8 @@ class DialogueCutscene extends Cutscene {
|
||||
dialogueBox = new DialogueBox(dialogueData.getAtt("box").getDefault("default"));
|
||||
add(dialogueBox);
|
||||
|
||||
|
||||
|
||||
next();
|
||||
} catch(e) {
|
||||
Logs.trace('Error while loading dialogue at ${dialoguePath}', ERROR);
|
||||
@@ -75,11 +78,9 @@ class DialogueCutscene extends Cutscene {
|
||||
return;
|
||||
}
|
||||
|
||||
for(c in charMap) {
|
||||
if (c.visible) {
|
||||
// TODO: remove character smoothly
|
||||
}
|
||||
}
|
||||
for(k=>c in charMap)
|
||||
if (k != curLine.char)
|
||||
c.hide();
|
||||
|
||||
if (charMap[curLine.char] != null)
|
||||
dialogueBox.popupChar(charMap[curLine.char]);
|
||||
@@ -88,7 +89,7 @@ class DialogueCutscene extends Cutscene {
|
||||
|
||||
public override function destroy() {
|
||||
super.destroy();
|
||||
FlxG.cameras.remove(camera);
|
||||
FlxG.cameras.remove(dialogueCamera);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,9 @@ class DialogueBox extends FunkinSprite {
|
||||
public var dialogueBoxData:Access;
|
||||
public var positions:Map<String, CharPosDef> = [];
|
||||
|
||||
public var textTypeSFX:String = Paths.sound('dialogue/text');
|
||||
public var nextSFX:String = Paths.sound('dialogue/next');
|
||||
|
||||
public function new(name:String) {
|
||||
super();
|
||||
try {
|
||||
@@ -30,6 +33,9 @@ class DialogueBox extends FunkinSprite {
|
||||
};
|
||||
}
|
||||
|
||||
if (dialogueBoxData.has.textSound) textTypeSFX = Paths.sound(dialogueBoxData.att.textSound);
|
||||
if (dialogueBoxData.has.nextSound) nextSFX = Paths.sound(dialogueBoxData.att.nextSound);
|
||||
|
||||
antialiasing = dialogueBoxData.getAtt("antialiasing").getDefault("true") == "true";
|
||||
screenCenter(X);
|
||||
y = FlxG.height - height;
|
||||
@@ -40,6 +46,8 @@ class DialogueBox extends FunkinSprite {
|
||||
active = false;
|
||||
Logs.trace('Couldn\'t load dialogue box "$name": ${e.toString()}', ERROR);
|
||||
}
|
||||
FlxG.sound.cache(nextSFX);
|
||||
FlxG.sound.cache(textTypeSFX);
|
||||
}
|
||||
|
||||
public function popupChar(char:DialogueCharacter) {
|
||||
@@ -47,15 +55,11 @@ class DialogueBox extends FunkinSprite {
|
||||
var pos = positions[char.positionName];
|
||||
if (pos == null) return;
|
||||
|
||||
if (!char.visible) {
|
||||
char.alpha = 0;
|
||||
char.visible = true;
|
||||
char.setPosition(pos.x, pos.y + 100);
|
||||
char.show(pos.y);
|
||||
}
|
||||
char.show((FlxG.width / 2) + pos.x, FlxG.height - pos.y);
|
||||
}
|
||||
|
||||
public function playBubbleAnim(bubble:String) {
|
||||
FlxG.sound.play(nextSFX);
|
||||
if (hasAnimation('$bubble-open'))
|
||||
playAnim('$bubble-open', true);
|
||||
else
|
||||
@@ -63,6 +67,15 @@ class DialogueBox extends FunkinSprite {
|
||||
visible = true;
|
||||
}
|
||||
|
||||
public override function update(elapsed:Float) {
|
||||
super.update(elapsed);
|
||||
if (isAnimFinished()) {
|
||||
var animName = getAnimName();
|
||||
if (animName.endsWith("-open"))
|
||||
playAnim(animName.substr(0, animName.length - 5));
|
||||
}
|
||||
}
|
||||
|
||||
public override function destroy() {
|
||||
super.destroy();
|
||||
positions = null;
|
||||
|
||||
@@ -8,6 +8,7 @@ import haxe.xml.Access;
|
||||
class DialogueCharacter extends FunkinSprite {
|
||||
public var charData:Access;
|
||||
public var curTween:FlxTween;
|
||||
public var curTweenContext:DialogueCharTweenContext = NONE;
|
||||
public var positionName:String;
|
||||
|
||||
public function new(name:String, position:String) {
|
||||
@@ -17,10 +18,11 @@ class DialogueCharacter extends FunkinSprite {
|
||||
charData = new Access(Xml.parse(Assets.getText(Paths.xml('dialogue/characters/$name'))).firstElement());
|
||||
loadSprite(Paths.image('dialogue/characters/${charData.getAtt('sprite').getDefault(name)}'));
|
||||
antialiasing = charData.getAtt('antialiasing').getDefault('true') == 'true';
|
||||
scale.scale(charData.has.scale ? Std.parseFloat(charData.att.scale).getDefault(1) : 1);
|
||||
updateHitbox();
|
||||
offset.set(
|
||||
charData.has.x ? Std.parseFloat(charData.att.x).getDefault(0) : 0,
|
||||
charData.has.y ? Std.parseFloat(charData.att.y).getDefault(0) : 0);
|
||||
scale.scale(charData.has.scale ? Std.parseFloat(charData.att.scale).getDefault(1) : 1);
|
||||
(charData.has.y ? Std.parseFloat(charData.att.y).getDefault(0) : 0) + this.height);
|
||||
for(anim in charData.nodes.anim)
|
||||
XMLUtil.addXMLAnimation(this, anim, true);
|
||||
} catch(e) {
|
||||
@@ -29,10 +31,31 @@ class DialogueCharacter extends FunkinSprite {
|
||||
visible = false;
|
||||
}
|
||||
|
||||
public function show(y:Float) {
|
||||
if (curTween != null)
|
||||
curTween.cancel();
|
||||
public function show(x:Float, y:Float) {
|
||||
if (curTweenContext != (curTweenContext = POPIN)) {
|
||||
setPosition(x, y + 100);
|
||||
if (curTween != null)
|
||||
curTween.cancel();
|
||||
|
||||
curTween = FlxTween.tween(this, {alpha: 1, y: y}, 0.5, {ease: FlxEase.cubeOut});
|
||||
alpha = 0;
|
||||
visible = true;
|
||||
|
||||
curTween = FlxTween.tween(this, {alpha: 1, y: y}, 0.2, {ease: FlxEase.quintOut});
|
||||
}
|
||||
}
|
||||
|
||||
public function hide() {
|
||||
if (curTweenContext != (curTweenContext = POPOUT)) {
|
||||
if (curTween != null)
|
||||
curTween.cancel();
|
||||
|
||||
curTween = FlxTween.tween(this, {alpha: 0, y: y + 100}, 0.2, {ease: FlxEase.quintIn});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum abstract DialogueCharTweenContext(Int) {
|
||||
var NONE = -1;
|
||||
var POPIN = 0;
|
||||
var POPOUT = 1;
|
||||
}
|
||||
Reference in New Issue
Block a user