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

Commit

Permalink
improve sustains centering
Browse files Browse the repository at this point in the history
  • Loading branch information
MaybeMaru committed Dec 25, 2023
1 parent c025082 commit 0b55ca1
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions source/funkin/objects/note/Sustain.hx
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,29 @@ class Sustain extends BasicNote {
public var pressed:Bool = false;
public var startedPress:Bool = false;
public var missedPress(default, set):Bool = false;
inline function set_missedPress(value:Bool) {
inline function set_missedPress(value:Bool):Bool {
color = (value && mustHit) ? MISS_COLOR : FlxColor.WHITE;
pressed = false;
moving = true;
offset.y = cutHeight * getCos();
return missedPress = value;
}

public var percentLeft(default, null):Float = 0.0;
public var cutHeight(default, null):Float = 0.0;

public function pressSustain() {
pressed = false;
public function pressSustain():Void {
if (Conductor.songPosition >= strumTime) {
pressed = true;
final susY:Float = getMillPos(strumTime - Conductor.songPosition);
percentLeft = repeatHeight / -susY;
clipRect.y = susY;
offset.y = susY * getCos();
if (susY <= -repeatHeight) {
moving = false;
setPositionToStrum();

// Update rect
cutHeight = getMillPos(strumTime - Conductor.songPosition);
clipRect.y = cutHeight;

// Sustain is finished
if (cutHeight <= -repeatHeight) {
kill();
}
}
Expand Down Expand Up @@ -89,12 +96,13 @@ class Sustain extends BasicNote {
loadFromSprite(curSkinData.baseSprite);

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

//playAnim("hold" + CoolUtil.directionArray[noteData] + "-end");
targetStrum = targetStrum;

final lastHeight = repeatHeight;
setTiles(1, 1);
//calcHeight = frameHeight;
calcHeight = frameHeight;
repeatHeight = lastHeight;
clipRect.width = repeatWidth;
}
Expand Down

0 comments on commit 0b55ca1

Please sign in to comment.