Do we need to use AssetPaths?



  • I was wondering if using AssetPaths provided any advantage (say it makes sure the files are included when compiling), or is referring to the path directly (e.g. "assets/image.png") fine?



  • yes it is fine. the advantage is that you can select a file from a popup menu.



  • it's just referring to the path ""assets/image.png" as you say (try doing trace (AssetPaths.yourfile__extension);).

    the files that get included are marked on your project.xml like this (example from my game):

    <assets path="assets" embed="true" />
    <assets path="user" embed="false"/>
    

    it's very handy if you know which file you want to open, these two are essentially the same:

    sprite.loadGraphic(AssetPaths.sprite__png);
    sprite.loadGraphic("pathToSprite/sprite.png");
    

  • administrators

    Also consider this: if the asset you're referencing with AssetPaths has been renamed or deleted, you will get a compiler error. If you reference the asset via a String path, you will only notice at runtime.


Log in to reply
 

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.