-
Notifications
You must be signed in to change notification settings - Fork 439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FlxG.assets: A way to overwrite and customize the way HaxeFlixel fetches or produces assets from ids #2982
Conversation
if I’m being honest, this is a very good change since it helps reduce imports (removing the need for |
There is some problem with async text/binary assets. They are not cached by lime. This can lead to inconsistencies between html5 and sys targets: a user expects to get the cached asset with // Project.xml
<assets path="assets" embed="false" preload="false"/>
// Main.hx
openfl.Assets.loadText(AssetPaths.atlas__json).onComplete(json -> {
// error on html5 "asset "atlas.json" exists, but only asynchronously"
trace(openfl.Assets.getText(AssetPaths.atlas__json));
}); Possible solutions:
|
The purpose of this PR is to add the ability to override the functionality of how flixel loads assets from string paths, I created What you're describing seems like a separate feature related to flixel's asset system, which may or may not be implemented regardless of whether this PR is merged. Do you agree? If so, I would make a new issue, if not, I may need you to elaborate, cuz I'm not seeing the relevance |
At brief look this pr api suggest text/binary assets can be cached, but in fact - they are not. May be it should be more clear in doc about that.
I am kinda agree. This pr fits for text/binary asset cache feature in a way that without new asset front-end it's hard to implement the feature. |
This would be great to see implemented. It would improve some of the issues I've had with overriding asset loading with Polymod. |
10/10. That's all I'm saying. |
Just making sure, is there any breaking changes with the introduction of these new features? |
There are never breaking changes on a minor release, if any PR causes breaking changes then it must be released in the next major version, i.e. 6.0.0, where this is for 5.9.0 Also any PR with breaking changes will list them and tips for migration. It will also use the "Breaking Change" label |
Fixes #2953
AssetsFrontEnd
Accessed via
FlxG.assets
. The main interface for the asset system. By default, OpenFl'sAsset system is used, which uses relative path strings to retrive assets, though you can completely
avoid Openfl's asset system by setting custom methods to the following dynamic fields:
getAssetUnsafe
,loadAsset
,exists
,isLocal
andlist
.Common Uses
The initial reason for making customizable asset system
was to allow for "hot-reloading", or testing new assets in your game without recompiling, with
each change. Say, if you would like a debug feature where you load assets from source assets,
rather than the assets copied over to your export folder, you could overwrite this system to do
just that.
Other potential uses for this are modding, bypassing the manifest and loading resources from
a remote location.
Quick Setup for "Hot-Reloading"
To simplify the process mentioned above, the
FLX_CUSTOM_ASSETS_DIRECTORY
flag was created.By adding
-DFLX_CUSTOM_ASSETS_DIRECTORY="../../../assets"
to your lime build commandit will automatically grab assets from your project root's assets folder rather than, the
default "export/hl/bin/assets". This will only work with a single asset root folder with one
asset library and will use the openfl asset system if the asset id starts with "flixel/" or
tries to references a specific library using the format: "libName:asset/path/file.ext".
To Do
Add coverage and/or unit testsNahCheck if sys, or implement on html or other non-sys targets somehowRename to singular AssetFrontEnd (check other front-ends for pattern)