Skip to content

Commit

Permalink
added a test sprite for antialiasing
Browse files Browse the repository at this point in the history
  • Loading branch information
Joalor64GH authored Nov 28, 2024
1 parent 5f7eb2a commit 5ae4709
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
Binary file added assets/images/testSpr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion source/options/Option.hx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Option {
public var type:OptionType;
public var value:Dynamic;
public var showPercentage:Bool = false;
public var showSillySprite:Bool = false;
public var onChange:Dynamic->Void;

public function new(name:String, desc:String, type:OptionType, value:Dynamic):Void {
Expand All @@ -36,7 +37,6 @@ class Option {
case OptionType.Choice(choices):
value = choices[FlxMath.wrap(choices.indexOf(value) + direction, 0, choices.length - 1)];
default:
// nothing
}

if (type != OptionType.Function && onChange != null)
Expand Down
34 changes: 33 additions & 1 deletion source/options/OptionsSubState.hx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ class OptionsSubState extends ExtendableSubState {
var holdTimer:FlxTimer;
var holdDirection:Int = 0;

var testSprite:FlxSprite;

public function new() {
super();

var option:Option = new Option(Localization.get("opAnti"), Localization.get("descAnti"), OptionType.Toggle, SaveData.settings.antialiasing);
option.onChange = (value:Dynamic) -> SaveData.settings.antialiasing = value;
option.onChange = (value:Dynamic) -> {
SaveData.settings.antialiasing = value;
reloadTheSprite();
};
option.showSillySprite = true;
options.push(option);

#if desktop
Expand Down Expand Up @@ -112,6 +118,9 @@ class OptionsSubState extends ExtendableSubState {
optionTxt.setFormat(Paths.font('vcr.ttf'), 60, FlxColor.WHITE, FlxTextAlign.LEFT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
optionTxt.ID = i;
grpOptions.add(optionTxt);

if (options[i].showSillySprite)
reloadTheSprite();
}

description = new FlxText(0, FlxG.height * 0.1, FlxG.width * 0.9, '', 28);
Expand Down Expand Up @@ -166,6 +175,9 @@ class OptionsSubState extends ExtendableSubState {

var option = options[curSelected];

if (testSprite != null)
testSprite.visible = option.showSillySprite;

if (option.desc != null) {
description.text = option.desc;
description.screenCenter(X);
Expand Down Expand Up @@ -209,4 +221,24 @@ class OptionsSubState extends ExtendableSubState {
}
}
}

private function reloadTheSprite() {
if (testSprite != null) {
testSprite.kill();
remove(testSprite);
testSprite.destroy();
}
testSprite = new GameSprite(700, 0).loadGraphic(Paths.image('testSpr'));
testSprite.scrollFactor.set();
testSprite.updateHitbox();
testSprite.screenCenter(Y);
add(testSprite);

new FlxTimer().start(0.01, (tmr:FlxTimer) -> {
if (testSprite.angle == -4)
FlxTween.angle(testSprite, testSprite.angle, 4, 4, {ease: FlxEase.quartInOut});
if (testSprite.angle == 4)
FlxTween.angle(testSprite, testSprite.angle, -4, 4, {ease: FlxEase.quartInOut});
}, 0);
}
}

0 comments on commit 5ae4709

Please sign in to comment.