Skip to content
This repository has been archived by the owner on Jan 26, 2025. It is now read-only.

Commit

Permalink
fix notes destroying
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Dec 25, 2023
1 parent 0b55ca1 commit 9990303
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
3 changes: 2 additions & 1 deletion source/funkin/graphics/FlxSkewRepeatSprite.hx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import openfl.display.BitmapData;
/*
TODO:
add skew y support (_matrix.b) and fix problems with dynamically sized tiles
fix skew on angles other than 0 and 180
*/

class FlxSkewRepeatSprite extends FlxRepeatSprite {
Expand Down Expand Up @@ -66,7 +67,7 @@ class FlxSkewRepeatSprite extends FlxRepeatSprite {

override function handleClipRect(tileFrame:FlxFrame, baseFrame:FlxFrame, tilePos:FlxPoint):Bool {
final _draw = super.handleClipRect(tileFrame, baseFrame, tilePos);
if (_draw) offsetSkew(tileFrame, baseFrame);
if (_draw && wigglePower != 0) offsetSkew(tileFrame, baseFrame);
return _draw;
}
}
12 changes: 6 additions & 6 deletions source/funkin/graphics/FlxSpriteExt.hx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package funkin.graphics;

import flixel.addons.effects.FlxSkewedSprite;
import flixel.util.FlxDestroyUtil;
import flixel.math.FlxMatrix;
import openfl.display.BitmapData;
Expand All @@ -8,7 +9,7 @@ import flixel.FlxBasic;
/*
Just FlxSprite but with helper functions
*/
class FlxSpriteExt extends FlxSprite {
class FlxSpriteExt extends FlxSkewedSprite {

public static final DEFAULT_SPRITE:SpriteJson = {
anims: [],
Expand All @@ -35,8 +36,6 @@ class FlxSpriteExt extends FlxSprite {
public var packer(default, null):PackerType = IMAGE;
public var imageKey(default, null):String = "::null::";

public var skew(default, null):FlxPoint = FlxPoint.get();

public function new(?X:Float = 0, ?Y:Float = 0, ?SimpleGraphic:FlxGraphicAsset):Void {
animOffsets = new Map<String, FlxPoint>();
animDatas = new Map<String, SpriteAnimation>();
Expand Down Expand Up @@ -178,8 +177,10 @@ class FlxSpriteExt extends FlxSprite {
}

if (skew.x != 0 || skew.y != 0) {
_matrix.c = Math.tan(skew.x * FlxAngle.TO_RAD);
_matrix.b = Math.tan(skew.y * FlxAngle.TO_RAD);
inline _skewMatrix.identity();
_skewMatrix.b = Math.tan(skew.y * FlxAngle.TO_RAD);
_skewMatrix.c = Math.tan(skew.x * FlxAngle.TO_RAD);
inline _matrix.concat(_skewMatrix);
}

getScreenPosition(_point, camera).subtractPoint(offset);
Expand Down Expand Up @@ -278,7 +279,6 @@ class FlxSpriteExt extends FlxSprite {
override function destroy() {
animOffsets = null;
animDatas = null;
skew = FlxDestroyUtil.put(skew);
super.destroy();
}

Expand Down
6 changes: 4 additions & 2 deletions source/funkin/objects/note/BasicNote.hx
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,13 @@ class BasicNote extends SmartSprite implements INoteData {
}

public var moving:Bool = true;
public var susLength:Float = 0.0;

override function update(elapsed:Float):Void {
super.update(elapsed);
if (targetStrum != null && moving) {
moveToStrum();
if (targetStrum != null) {
if (moving) moveToStrum();
active = Conductor.songPosition < (strumTime + susLength + getPosMill(NoteUtil.swagHeight * 2));
}
}

Expand Down
5 changes: 1 addition & 4 deletions source/funkin/objects/note/Sustain.hx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package funkin.objects.note;
import flixel.graphics.frames.FlxFrame;

class Sustain extends BasicNote {
public var susLength:Float = 0.0;

public function new(noteData:Int = 0, strumTime:Float = 0.0, susLength:Float = 0.0, skin:String = "default", ?parent:Note):Void {
clipRect = FlxRect.get();
super(noteData, strumTime, skin); // Load skin
Expand Down Expand Up @@ -96,9 +94,8 @@ class Sustain extends BasicNote {
loadFromSprite(curSkinData.baseSprite);

playAnim("hold" + CoolUtil.directionArray[noteData]);

//playAnim("hold" + CoolUtil.directionArray[noteData] + "-end");
targetStrum = targetStrum;
smoothTiles = Math.round(125 / height);

final lastHeight = repeatHeight;
setTiles(1, 1);
Expand Down

0 comments on commit 9990303

Please sign in to comment.