stages now works without xmls
This commit is contained in:
@@ -91,6 +91,7 @@ class PlayState extends MusicBeatState
|
||||
public var cpuStrums:FlxTypedGroup<Strum>;
|
||||
|
||||
public var camZooming:Bool = false;
|
||||
public var camZoomingInterval:Int = 4;
|
||||
public var curSong:String = "";
|
||||
public var curStage:String = "";
|
||||
|
||||
@@ -777,8 +778,9 @@ class PlayState extends MusicBeatState
|
||||
// FlxG.watch.addQuick('VOL', vocals.amplitudeLeft);
|
||||
// FlxG.watch.addQuick('VOLRight', vocals.amplitudeRight);
|
||||
|
||||
iconP1.setGraphicSize(Std.int(FlxMath.lerp(150, iconP1.width, 0.50)));
|
||||
iconP2.setGraphicSize(Std.int(FlxMath.lerp(150, iconP2.width, 0.50)));
|
||||
// TODO: FPS-compatible lerping
|
||||
iconP1.scale.set(FlxMath.lerp(iconP1.scale.x, 1, 0.33), FlxMath.lerp(iconP1.scale.y, 1, 0.33));
|
||||
iconP2.scale.set(FlxMath.lerp(iconP2.scale.x, 1, 0.33), FlxMath.lerp(iconP2.scale.y, 1, 0.33));
|
||||
|
||||
iconP1.updateHitbox();
|
||||
iconP2.updateHitbox();
|
||||
@@ -1336,6 +1338,7 @@ class PlayState extends MusicBeatState
|
||||
{
|
||||
if (!note.wasGoodHit)
|
||||
{
|
||||
camZooming = true;
|
||||
if (note.mustPress) {
|
||||
// TODO: See TODO above
|
||||
scripts.call("onPlayerHit", [note]);
|
||||
@@ -1434,20 +1437,21 @@ class PlayState extends MusicBeatState
|
||||
}
|
||||
|
||||
// HARDCODING FOR MILF ZOOMS!
|
||||
if (curSong.toLowerCase() == 'milf' && curBeat >= 168 && curBeat < 200 && camZooming && FlxG.camera.zoom < 1.35)
|
||||
// if (curSong.toLowerCase() == 'milf' && curBeat >= 168 && curBeat < 200 && camZooming && FlxG.camera.zoom < 1.35)
|
||||
// {
|
||||
// FlxG.camera.zoom += 0.015;
|
||||
// camHUD.zoom += 0.03;
|
||||
// }
|
||||
|
||||
if (camZoomingInterval < 1) camZoomingInterval = 1;
|
||||
if (camZooming && FlxG.camera.zoom < 1.35 && curBeat % camZoomingInterval == 0)
|
||||
{
|
||||
FlxG.camera.zoom += 0.015;
|
||||
camHUD.zoom += 0.03;
|
||||
}
|
||||
|
||||
if (camZooming && FlxG.camera.zoom < 1.35 && curBeat % 4 == 0)
|
||||
{
|
||||
FlxG.camera.zoom += 0.015;
|
||||
camHUD.zoom += 0.03;
|
||||
}
|
||||
|
||||
iconP1.setGraphicSize(Std.int(iconP1.width + 30));
|
||||
iconP2.setGraphicSize(Std.int(iconP2.width + 30));
|
||||
iconP1.scale.set(1.2, 1.2);
|
||||
iconP2.scale.set(1.2, 1.2);
|
||||
|
||||
iconP1.updateHitbox();
|
||||
iconP2.updateHitbox();
|
||||
|
||||
+71
-69
@@ -27,79 +27,81 @@ class Stage extends FlxBasic implements IBeatReceiver {
|
||||
} catch(e) {
|
||||
// TODO: handler
|
||||
trace(e.details());
|
||||
return;
|
||||
}
|
||||
var spritesParentFolder = "";
|
||||
if (stageXML.has.zoom) {
|
||||
var parsed:Null<Float> = Std.parseFloat(stageXML.att.zoom);
|
||||
if (parsed != null) PlayState.instance.defaultCamZoom = parsed;
|
||||
}
|
||||
if (stageXML.has.folder) {
|
||||
spritesParentFolder = stageXML.att.folder;
|
||||
if (spritesParentFolder.charAt(spritesParentFolder.length-1) != "/") spritesParentFolder = spritesParentFolder + "/";
|
||||
}
|
||||
if (stageXML.has.name) PlayState.instance.curStage = stageXML.att.name;
|
||||
if (stageXML != null) {
|
||||
|
||||
var spritesParentFolder = "";
|
||||
if (stageXML.has.zoom) {
|
||||
var parsed:Null<Float> = Std.parseFloat(stageXML.att.zoom);
|
||||
if (parsed != null) PlayState.instance.defaultCamZoom = parsed;
|
||||
}
|
||||
if (stageXML.has.folder) {
|
||||
spritesParentFolder = stageXML.att.folder;
|
||||
if (spritesParentFolder.charAt(spritesParentFolder.length-1) != "/") spritesParentFolder = spritesParentFolder + "/";
|
||||
}
|
||||
if (stageXML.has.name) PlayState.instance.curStage = stageXML.att.name;
|
||||
|
||||
for(node in stageXML.elements) {
|
||||
switch(node.name) {
|
||||
case "sprite" | "spr" | "sparrow":
|
||||
var spr = new FlxSprite();
|
||||
spr.antialiasing = true;
|
||||
if (!node.has.sprite || !node.has.name || !node.has.x || !node.has.y) continue;
|
||||
|
||||
for(node in stageXML.elements) {
|
||||
switch(node.name) {
|
||||
case "sprite" | "spr" | "sparrow":
|
||||
var spr = new FlxSprite();
|
||||
spr.antialiasing = true;
|
||||
if (!node.has.sprite || !node.has.name || !node.has.x || !node.has.y) continue;
|
||||
|
||||
if (Assets.exists(Paths.file('images/$spritesParentFolder${node.att.sprite}', TEXT))) {
|
||||
spr.frames = Paths.getSparrowAtlas('$spritesParentFolder${node.att.sprite}');
|
||||
} else {
|
||||
spr.loadGraphic(Paths.image('$spritesParentFolder${node.att.sprite}'));
|
||||
}
|
||||
var x:Null<Float> = Std.parseFloat(node.att.x);
|
||||
var y:Null<Float> = Std.parseFloat(node.att.y);
|
||||
if (x != null) spr.x = x;
|
||||
if (y != null) spr.y = y;
|
||||
if (node.has.scroll) {
|
||||
var scroll:Null<Float> = Std.parseFloat(node.att.scroll);
|
||||
if (scroll != null) spr.scrollFactor.set(scroll, scroll);
|
||||
}
|
||||
if (node.has.scale) {
|
||||
var scale:Null<Float> = Std.parseFloat(node.att.scale);
|
||||
if (scale != null) spr.scale.set(scale, scale);
|
||||
}
|
||||
if (node.has.updateHitbox && node.att.updateHitbox == "true") spr.updateHitbox();
|
||||
|
||||
for(anim in node.nodes.anim) CoolUtil.addXMLAnimation(spr, anim);
|
||||
|
||||
stageSprites.set(node.att.name, spr);
|
||||
PlayState.instance.add(spr);
|
||||
case "boyfriend" | "bf":
|
||||
if (node.has.x) {
|
||||
if (Assets.exists(Paths.file('images/$spritesParentFolder${node.att.sprite}', TEXT))) {
|
||||
spr.frames = Paths.getSparrowAtlas('$spritesParentFolder${node.att.sprite}');
|
||||
} else {
|
||||
spr.loadGraphic(Paths.image('$spritesParentFolder${node.att.sprite}'));
|
||||
}
|
||||
var x:Null<Float> = Std.parseFloat(node.att.x);
|
||||
if (x != null) PlayState.instance.boyfriend.x = x;
|
||||
}
|
||||
if (node.has.y) {
|
||||
var y:Null<Float> = Std.parseFloat(node.att.y);
|
||||
if (y != null) PlayState.instance.boyfriend.y = y;
|
||||
}
|
||||
PlayState.instance.add(PlayState.instance.boyfriend);
|
||||
case "girlfriend" | "gf":
|
||||
if (node.has.x) {
|
||||
var x:Null<Float> = Std.parseFloat(node.att.x);
|
||||
if (x != null) PlayState.instance.gf.x = x;
|
||||
}
|
||||
if (node.has.y) {
|
||||
var y:Null<Float> = Std.parseFloat(node.att.y);
|
||||
if (y != null) PlayState.instance.gf.y = y;
|
||||
}
|
||||
PlayState.instance.add(PlayState.instance.gf);
|
||||
case "dad" | "opponent":
|
||||
if (node.has.x) {
|
||||
var x:Null<Float> = Std.parseFloat(node.att.x);
|
||||
if (x != null) PlayState.instance.dad.x = x;
|
||||
}
|
||||
if (node.has.y) {
|
||||
var y:Null<Float> = Std.parseFloat(node.att.y);
|
||||
if (y != null) PlayState.instance.dad.y = y;
|
||||
}
|
||||
PlayState.instance.add(PlayState.instance.dad);
|
||||
if (x != null) spr.x = x;
|
||||
if (y != null) spr.y = y;
|
||||
if (node.has.scroll) {
|
||||
var scroll:Null<Float> = Std.parseFloat(node.att.scroll);
|
||||
if (scroll != null) spr.scrollFactor.set(scroll, scroll);
|
||||
}
|
||||
if (node.has.scale) {
|
||||
var scale:Null<Float> = Std.parseFloat(node.att.scale);
|
||||
if (scale != null) spr.scale.set(scale, scale);
|
||||
}
|
||||
if (node.has.updateHitbox && node.att.updateHitbox == "true") spr.updateHitbox();
|
||||
|
||||
for(anim in node.nodes.anim) CoolUtil.addXMLAnimation(spr, anim);
|
||||
|
||||
stageSprites.set(node.att.name, spr);
|
||||
PlayState.instance.add(spr);
|
||||
case "boyfriend" | "bf":
|
||||
if (node.has.x) {
|
||||
var x:Null<Float> = Std.parseFloat(node.att.x);
|
||||
if (x != null) PlayState.instance.boyfriend.x = x;
|
||||
}
|
||||
if (node.has.y) {
|
||||
var y:Null<Float> = Std.parseFloat(node.att.y);
|
||||
if (y != null) PlayState.instance.boyfriend.y = y;
|
||||
}
|
||||
PlayState.instance.add(PlayState.instance.boyfriend);
|
||||
case "girlfriend" | "gf":
|
||||
if (node.has.x) {
|
||||
var x:Null<Float> = Std.parseFloat(node.att.x);
|
||||
if (x != null) PlayState.instance.gf.x = x;
|
||||
}
|
||||
if (node.has.y) {
|
||||
var y:Null<Float> = Std.parseFloat(node.att.y);
|
||||
if (y != null) PlayState.instance.gf.y = y;
|
||||
}
|
||||
PlayState.instance.add(PlayState.instance.gf);
|
||||
case "dad" | "opponent":
|
||||
if (node.has.x) {
|
||||
var x:Null<Float> = Std.parseFloat(node.att.x);
|
||||
if (x != null) PlayState.instance.dad.x = x;
|
||||
}
|
||||
if (node.has.y) {
|
||||
var y:Null<Float> = Std.parseFloat(node.att.y);
|
||||
if (y != null) PlayState.instance.dad.y = y;
|
||||
}
|
||||
PlayState.instance.add(PlayState.instance.dad);
|
||||
}
|
||||
}
|
||||
}
|
||||
stageScript = Script.create(Paths.script('data/stages/$stage'));
|
||||
|
||||
Reference in New Issue
Block a user