Gamua / Starling-Framework

The Cross Platform Game Engine
http://www.starling-framework.org
Other
2.85k stars 819 forks source link

AssetManager should expose it's _starling property and should allow the user to pass a custom starling instance #862

Open BigPhilCombo opened 8 years ago

BigPhilCombo commented 8 years ago

It would be beneficial if we could specify the starling instance we'd like to use to the Asset Manager. If not value is specified it could default to Starling.current.

It would be also helpful to expose that value via a public property so it could be used in conjunction with Feathers themes

PrimaryFeather commented 8 years ago

Actually, you can already do that, at least indirectly:

var myStarling:Starling = /* ... */
var assetManager:AssetManager = new AssetManager();

myStarling.makeCurrent(); // <-- !!
assetManager.loadQueue();

Whatever is the current Starling instance when you call loadQueue will be stored with the AssetManager. Even if Starling.current changes later, the AssetManager will always work with that instance.

Is that what you were looking for?

PrimaryFeather commented 8 years ago

(Accidentally closed. Please close yourself if you find the solution acceptable.)

BigPhilCombo commented 8 years ago

That's fine to make the starling you want current before instantiating your asset manager. It would be helpful to expose that internal starling reference in the Asset Manager though, because once loading has completed there is no guarantee which starling instance will be the appropriate one. So if the asset manager had it's property exposed, when loading is complete I can just pass the Asset Manager to any classes that need it and they could use the AM's 'starling' property to upload textures to the correct context.

On Wed, May 11, 2016 at 6:09 AM, Daniel Sperl notifications@github.com wrote:

(Accidentally closed. Please close yourself if you find the solution acceptable.)

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/Gamua/Starling-Framework/issues/862#issuecomment-218417162

Phillip Chertok

PrimaryFeather commented 8 years ago

I see, thanks for the additional info! I'll definitely consider adding such a property. One plan for Starling 2.1 would be to rewrite / enhance the AssetManager for more flexibility; that might be a good time to do just that.

Thanks again for the suggestion!