-
Forgive me if I'm in the wrong place. I've been coding a long time but don't work with GitHub a lot and I'm new to HaxeFlixel. Contrary to my usual way of doing things I am actually following the TurnBasedRPG tutorial step by step and I've hit a major snag that's got me completely baffled. This is exactly the sample code I copied: package;
import flixel.FlxSprite;
import flixel.tweens.FlxEase;
import flixel.tweens.FlxTween;
class Coin extends FlxSprite
{
public function new(x:Float, y:Float)
{
super(x, y);
loadGraphic(AssetPaths.coin__png, false, 8, 8);
// loadGraphic(AssetPaths.player__png, true, 16, 16);
}
override function kill()
{
alive = false;
FlxTween.tween(this, {alpha: 0, y: y - 16}, 0.33, {ease: FlxEase.circOut, onComplete: finishKill});
}
function finishKill(_)
{
exists = false;
}
} Aside from the commented loadGraphic. Despite the file coin.png being in the exact same assets/images directory as player.png, I'm getting the build error "Class<AssetPaths> has no field coin__png". I can see coin.png both through the OS and in the Visual Code Studio explorer. If I swap the commented line in and comment out the coin__png line, it works (although obviously using the player PNG). The only thing I can think of is some part of the build chain hasn't re-read the assets directory contents but I've been banging on it for 15 minutes and it keeps giving me the same error. Edit: Closing Visual Studio and reopening it solved the problem but...shouldn't it have seen the coin.png file before? Isn't that a bit drastic? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The asset path macro results tend to be cached a bit too agressively unfortunatenly. A more "lightweight" method of refreshing it is F1 -> Haxe: Restart Language Server. Note that compilation should still work, this is likely just a "diagnostics" error. Also note that you can always use string asset paths instead, the macro is just for convenience - |
Beta Was this translation helpful? Give feedback.
The asset path macro results tend to be cached a bit too agressively unfortunatenly. A more "lightweight" method of refreshing it is F1 -> Haxe: Restart Language Server. Note that compilation should still work, this is likely just a "diagnostics" error.
Also note that you can always use string asset paths instead, the macro is just for convenience -
loadGraphic("assets/images/coin.png")
.