flaxen icon indicating copy to clipboard operation
flaxen copied to clipboard

Add caching semi-static component

Open scriptorum opened this issue 10 years ago • 0 comments

Look into adding some mechanism for creating and caching static components on the fly. Some ideas:

var image = Image.cache("art/mybutt.png"); // cleanest but possibly most work; macro magic?
var layer = ComponentCache.get(Layer, [30]); // easiest to implement but not pretty
var offset = @singleton(Offset.zero()); // not sure if anything like this is even possible in Haxe

It seems likely these techniques will take too much memory or runtime, but I wanted to spend some thought on it. If it's not worth doing, the user is better off caching the component themselves. They could always do something like:

f.newComponentSet("layer30").add(new Layer(30));
f.addSet(myEnt, "layer30"); // would add the same instance each time

scriptorum avatar Feb 03 '15 19:02 scriptorum