Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Apr 9, 2024
1 parent 3f03029 commit b7e615a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 26 deletions.
18 changes: 12 additions & 6 deletions source/funkin/graphics/FlxSpriteExt.hx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ typedef SpriteJson = {
/*
Just FlxSprite but with helper functions
*/
class FlxSpriteExt extends FlxSkewedSprite {

class FlxSpriteExt extends FlxSkewedSprite
{
public static final DEFAULT_SPRITE:SpriteJson = {
anims: [],
imagePath: "keoiki",
Expand Down Expand Up @@ -406,11 +406,17 @@ class FlxSpriteExt extends FlxSkewedSprite {

public var scaleOffset:Bool = false;

public function applyCurOffset(forced:Bool = false):Void {
if (animation.curAnim != null) {
if(existsOffsets(animation.curAnim.name)) {
public function applyCurOffset(forced:Bool = false):Void
{
if (animation.curAnim != null)
{
if(existsOffsets(animation.curAnim.name))
{
var animPoint = animOffsets.get(animation.curAnim.name);
var point = CoolUtil.point;
point.copyFrom(animOffsets.get(animation.curAnim.name));
point.x = animPoint.x;
point.y = animPoint.y;

if (!point.isZero() || forced) {

if (flippedOffsets) point.x = -point.x; // Flip X
Expand Down
5 changes: 3 additions & 2 deletions source/funkin/objects/Character.hx
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,9 @@ class Character extends FlxSpriteExt
public var _singHoldTimer:Float = 0;
public var holdFrame:Int = 2;

public function sing(noteData:Int = 0, altAnim:String = '', hit:Bool = true):Void {
final singAnim = 'sing${CoolUtil.directionArray[noteData%Conductor.NOTE_DATA_LENGTH]}$altAnim';
public function sing(noteData:Int = 0, altAnim:String = '', hit:Bool = true):Void
{
final singAnim:String = 'sing${CoolUtil.directionArray[noteData % Conductor.NOTE_DATA_LENGTH]}$altAnim';
if (!existsOffsets(singAnim)) return;

holdTimer = 0;
Expand Down
31 changes: 15 additions & 16 deletions source/funkin/objects/NotesGroup.hx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ class NotesGroup extends Group
{
public static var instance:NotesGroup;
public var SONG:SwagSong;
var game:PlayState;
var boyfriend:Character;
var dad:Character;
public var game:PlayState;
public var boyfriend:Character;
public var dad:Character;

public static var songSpeed:Float = 1.0;
public var curSong:String = 'test';
Expand Down Expand Up @@ -61,7 +61,8 @@ class NotesGroup extends Group

inline function hitNote(note:Note, character:Character, botplayCheck:Bool = false, prefBot:Bool = false) {
note.wasGoodHit = true;
if (note.child != null) note.child.startedPress = true;
if (note.child != null)
note.child.startedPress = true;

if (character != null) {
character.sing(note.noteData, note.altAnim);
Expand Down Expand Up @@ -501,7 +502,7 @@ class NotesGroup extends Group
if (removeList.length > 0) removeList.splice(0, removeList.length);
if (ignoreList.length > 0) ignoreList.splice(0, ignoreList.length);

notes.forEachAlive(function (note:BasicNote) {
notes.forEachAlive((note:BasicNote) -> {
if (isCpuNote(note))
return;

Expand Down Expand Up @@ -595,14 +596,14 @@ class NotesGroup extends Group

inline function checkStrums(array:Array<NoteStrum>):Void {
array.fastForEach((strum, i) -> {
final anim = strum.animation.curAnim;
if (anim == null) continue; // Lil null check

if (strum.getControl(JUST_PRESSED)) if (!anim.name.startsWith('confirm'))
strum.playStrumAnim('pressed');

if (!strum.getControl())
strum.playStrumAnim('static');
if (strum.animation.curAnim != null) // Lil null check
{
if (strum.getControl(JUST_PRESSED)) if (!strum.animation.curAnim.name.startsWith('confirm'))
strum.playStrumAnim('pressed');

if (!strum.getControl())
strum.playStrumAnim('static');
}
});
}

Expand All @@ -620,9 +621,7 @@ class NotesGroup extends Group
if (char == null) return;
if (char.animation.curAnim == null) return;

var anim = char.animation.curAnim;
var name:String = anim.name;

var name:String = char.animation.curAnim.name;
var overSinging:Bool =
(char.holdTimer > (Conductor.stepCrochetMills * Conductor.STEPS_PER_BEAT)
&& name.startsWith('sing')
Expand Down
5 changes: 3 additions & 2 deletions source/funkin/states/PlayState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -836,10 +836,11 @@ class PlayState extends MusicBeatState
addCharScript(newChar);

switch (type) {
case 'dad': dad = newChar;
case 'dad': dad = newChar; notesGroup.dad = newChar;
case 'girlfriend' | 'gf': gf = newChar;
default: boyfriend = newChar;
default: boyfriend = newChar; notesGroup.boyfriend = newChar;
}

cameraMovement();
}

Expand Down

0 comments on commit b7e615a

Please sign in to comment.