fix html5 compile and input

This commit is contained in:
Kade M 2021-07-11 23:26:23 -07:00
parent 361555cfa3
commit 4f947ca6e6
3 changed files with 33 additions and 13 deletions

View File

@ -1,3 +1,4 @@
#if sys
package;
import lime.app.Application;
@ -171,4 +172,5 @@ class Caching extends MusicBeatState
FlxG.switchState(new TitleState());
}
}
}
#end

View File

@ -130,26 +130,44 @@ class Paths
inline static public function getSparrowAtlas(key:String, ?library:String, ?isCharacter:Bool = false)
{
var usecahce = FlxG.save.data.cacheImages;
#if !cpp
usecahce = false;
#end
if (isCharacter)
if (FlxG.save.data.cacheImages)
if (usecahce)
#if cpp
return FlxAtlasFrames.fromSparrow(imageCached(key), file('images/characters/$key.xml', library));
#else
return null;
#end
else
return FlxAtlasFrames.fromSparrow(image('characters/$key'), file('images/characters/$key.xml'));
return FlxAtlasFrames.fromSparrow(image(key, library), file('images/$key.xml', library));
}
#if cpp
inline static public function imageCached(key:String):FlxGraphic
{
var data = Caching.bitmapData.get(key);
trace('finding ${key} - ${data.bitmap}');
return data;
}
#end
inline static public function getPackerAtlas(key:String, ?library:String, ?isCharacter:Bool = false)
{
var usecahce = FlxG.save.data.cacheImages;
#if !cpp
usecahce = false;
#end
if (isCharacter)
if (FlxG.save.data.cacheImages)
if (usecahce)
#if cpp
return FlxAtlasFrames.fromSpriteSheetPacker(imageCached(key), file('images/$key.txt', library));
#else
return null;
#end
else
return FlxAtlasFrames.fromSpriteSheetPacker(image('characters/$key'), file('images/characters/$key.txt'));
return FlxAtlasFrames.fromSpriteSheetPacker(image(key, library), file('images/$key.txt', library));

View File

@ -1209,7 +1209,6 @@ class PlayState extends MusicBeatState
FlxG.stage.addEventListener(KeyboardEvent.KEY_DOWN, handleInput);
FlxG.stage.addEventListener(KeyboardEvent.KEY_UP, releaseInput);
super.create();
}
@ -2220,8 +2219,10 @@ class PlayState extends MusicBeatState
{
GlobalVideo.get().stop();
remove(videoSprite);
#if sys
FlxG.stage.window.onFocusOut.remove(focusOut);
FlxG.stage.window.onFocusIn.remove(focusIn);
#end
removedVideo = true;
}
#if windows
@ -3451,8 +3452,6 @@ class PlayState extends MusicBeatState
};
#end
var nonCpp = false;
// Prevent player input if botplay is on
if (PlayStateChangeables.botPlay)
{
@ -3461,10 +3460,6 @@ class PlayState extends MusicBeatState
releaseArray = [false, false, false, false];
}
#if !cpp
nonCpp = true;
#end
var anas:Array<Ana> = [null, null, null, null];
for (i in 0...pressArray.length)
@ -3484,7 +3479,7 @@ class PlayState extends MusicBeatState
});
}
if ((KeyBinds.gamepad && !FlxG.keys.justPressed.ANY) || nonCpp)
if ((KeyBinds.gamepad && !FlxG.keys.justPressed.ANY))
{
// PRESSES, check for note hits
if (pressArray.contains(true) && generatedMusic)
@ -3521,6 +3516,7 @@ class PlayState extends MusicBeatState
}
else
{
directionsAccounted[daNote.noteData] = true;
possibleNotes.push(daNote);
directionList.push(daNote.noteData);
}
@ -3536,6 +3532,9 @@ class PlayState extends MusicBeatState
}
possibleNotes.sort((a, b) -> Std.int(a.strumTime - b.strumTime));
var hit = [false,false,false,false];
if (perfectMode)
goodNoteHit(possibleNotes[0]);
else if (possibleNotes.length > 0)
@ -3550,10 +3549,11 @@ class PlayState extends MusicBeatState
}
for (coolNote in possibleNotes)
{
if (pressArray[coolNote.noteData])
if (pressArray[coolNote.noteData] && !hit[coolNote.noteData])
{
if (mashViolations != 0)
mashViolations--;
hit[coolNote.noteData] = true;
scoreTxt.color = FlxColor.WHITE;
var noteDiff:Float = -(coolNote.strumTime - Conductor.songPosition);
anas[coolNote.noteData].hit = true;