I'm willing to fully exploit the AssetManager from Libgdx and all its Loaders.
But i have problem understanding this so special link between Skin and TextureAtlas.
I want to use the JSON way of creating skins as much as possible.
In the wiki i can read this :
Note the JSON does not describe texture regions, ninepatche splits, or other information which comes from the texture atlas
In the SkinLoader page i read this :
AssetLoader for Skin instances. (1)All Texture and BitmapFont instances will be loaded as dependencies. Passing a SkinLoader.SkinParameter allows the (2)exact name of the texture associated with the skin to be specified. Otherwise the skin texture is looked up just as with a call to (3)Skin.Skin(com.badlogic.gdx.files.FileHandle). A SkinLoader.SkinParameter also allows named resources to be set that will be added to the skin before loading the json file, meaning that they can be referenced from inside the json file itself. This is useful for dynamic resources such as a BitmapFont generated through FreeTypeFontGenerator.
So here is what where my thoughts when i read this.
(1) All texture. They use the plural so i guess they're mentioning the texture (as a drawable) that i may need for a button, for example.
(2) The exact name of THE texture. So now, maybe they're talking about the TextureAtlas, because SkinParameter as only two fields resources and textureAtlasPath.
(3) This seems to confirm the (2)
So if i understand, if i want to use this method to load my Skin i MUST use the TexturePacker and the TextureAtlas.
Can you confirm me that i understood that correctly and that there are NO WAY of initializing the texture which will be used in my skin without a TextureAtlas but with simple png files ?
And if use the TexturePacker to create my pack file, obviously i will have to repack everything when i make a modification on one of my texture, right ?
Skin does support using separate Textures for your various drawables, but it's clunky because it's not really something anyone should be doing. What you could do is create TextureRegion drawables out of your Textures, and register them by name with the Skin before telling the skin to load the json file, like this:
TextureRegionDrawable someButtonImage = new TextureRegionDrawable(
new TextureRegion(someButtonTextureThatIsAlreadyLoaded));
Skin skin = new Skin(); //don't give it a json file yet
skin.add("someButton", someButtonImage);
skin.load(Gdx.files.internal("mySkin.json"));
Now your Json could use "someButton" as a value for any drawable paramter in the skin.
But if you're using AssetManager, you can only do this if you have already loaded all your necessary textures outside of the AssetManager, so you can pass them into your SkinLoader's SkinParameter as a Map of names to TextureRegionDrawables.
Either way, you would be typing a lot of code to manually load all those textures, when you could just be using a texture atlas, which will perform better anyway. You can set up your run configuration in your IDE to pack your atlas for you each time you start your app, if you're concerned about having to do that every time you change an image in your skin.
The exception to all the above is for BitmapFonts, which do not have to be part of the same atlas as everything else for you to be able to load them purely from Json. Skin treats it as a special case.
Anyway, here's how I load my skin along with the atlas it uses to retrieve its drawables:
assetManager.load("mySkin.json", Skin.class, new SkinLoader.SkinParameter("myAtlas.atlas"));
Related
Is there any way to get a list of bitmap resource (eg png file) using as3? I know that I can go through the all child of the swf and check if each child is a shape or not, if yes, then I can get back the bitmap data by
var bmd:BitmapData = new BitmapData(obj.width, obj.height, true, 0);
bmd.draw(obj);
and then write out the bmd as a png file. However, by doing this I cannot know which png resource this object associate with, also if the object instance is inside an animation, this approach may not successfully capture the bitmap data correctly. Any better idea?
I believe you can play with these libraries as3swf (as3swf is a low level Actionscript 3 library to parse, create, modify and publish SWF files.) and Velocity 9 SWF Inspector (A handy little tool to peek inside SWF files)
I made an editor that allows to create some custom space ships for game I'm making.
This editor is meant for the player and his ships are saved in SharedObject without a problem.
What i would like to do is to use the editor to create some ships for enemies and use them later when designing levels.
I was thinking about writing the Ship object to ByteArray and than tracing them so i can copy and paste them to code and read them back to object but this does not seem to work since what i get from tracing a ByteArray is only class name and few undefined symbols that i can't even paste here.
The standard trace panel in flash is text based, therefore no bytes can be output properly (ByteArray).
I'm not pretty sure what are the types of objects you need to store, but you can do two things:
Save ByteArray to UTF8 external file; then read it back to ByteArray, and you're on the road again
if you need to trace them out, Base64 encode them (simple but powerful class here: https://gist.github.com/burakkirkil/4051420)
It seems as though every actionscript file (not custom ones) is automatically included when coding in the timeline's actions, so I'm wondering if it's necessary to import the files through the code. Are there any advantages? Can I prevent flash from importing every file to reduce the size of my flash application (SWF)?.
For example, I don't need to import MovieClip to use the MovieClip class in timeline actions.
You can indeed load external assets, that is, anything of SWF, MP3, WAV, JPG or any byte sequence you have a decoder for, then parse it via code, then use in your Flash app. The advantages are flexibility, for example, if a user has all sounds turned off, you are free to not load large music for him thus saving him some traffic - this might be crucial for some people out there. There are also disadvantages, because the files (assets) in SWF are available from the start of your app, and because the connection can get lost at any moment, you might not receive your external files in time for the app to use, or not receive them at all.
Not importing in order to reduce the SWF size? I'd say reduce the size or quality of those assets instead. The actual mess with Loaders is something you should avoid unless you have dynamic downloadable content (some extra levels' metadata maybe) which you plan to generate on a timely basis in order to attract longer attention to your app.
In short, all static content is better embedded, all dynamic content should be loaded afterwards.
Compiling FLA file doesn't embed every AS file in the resulting SWF. My test directory structure.
Work Directory
file.fla
ClassA.as
ClassB.as
The code on my timeline.
var a:ClassA = new ClassA();
The resulting SWF only contain the ClassA.
For multiple SWF files with code, every SWF embed the class. It's your job to tell the compiler.
If you are using FLEXSDK, you can look to these parameters.
-link-report file.xml : Generate a file containing all AS file include at compilation.
-load-externs file.xml : Exclude all class containt in the file.
If you are using Adobe Flash exclude class article
I want to know how to load external class files(.as files) in actionscript but don't have to know the class file's name. Think of it like loading mods in minecraft with forge mod loader, it doesn't know the main class of the mod's file name, yet it successfully loads the mod. I want to know if something like this is possible in actionscript 3.0 because I feel like making a tower defense game that isn't like the others out there but have it so it can be modded and have mods loaded but of course I have to load the class file without knowing the class file's name.
Note: I don't got access to Adobe Air so I can't use anything that requires Adobe Air.
You want to load a particular .as file AFTER or BEFORE compilation? After the compilation it is hardly possible - the file would not be compiled and therefore it would be useless. Why don't you use a swf or some kind of XML/JSON with settings in that case? Before the compilation you would still need to identify it by it's package name/name.
Basically, you want a plugin management system.
In AS3, it is not possible to "load" a .as file on execution, because it is a (uncompiled) source file. But, it is possible to load another swf and to use the classes within it.
Your process should probably be something like this :
Get a list of the plugins/addons. If you were using AIR, it would have been possible by browsing the content of a folder. Since you're not, you'll probably need to use a listing file (basically, a file that say "Here's the list&path of the plugins you need to load".
Load each swf file
(possibly) call a initialization method for each plugin.
You may wish to look into the way OSMF manages plugins, for example : http://osmf.org/dev/osmf/OtherPDFs/osmf_plugin_dev_guide.pdf
i am working on a project and i got stuck on this one thing, i got a bvh file with an animation which i put on a biped in 3dsmax then i export every frame in to a json file with the thee.js json exporter and then when it gets played i remove the old mesh and add a new one. This causes the model to upload multiple times, which ofcourse is not what i want.
I use the jsonloader and i wondered if there was a way to update only the geometry every frame? Also i made those seperate files because i dont use a skin and i dont have morphtargets because i use a bvh file in 3dsmax.
It would be awesome if someone could help me with this
Example: http://www.deschaatssport.nl/3dsportsvisualiser/versie3/?p=3# (press the play button)
Mathijs Jansen
Assuming your JSON exporter keeps the number and order of faces/vertices intact, you could do something like this:
Load the initial model as you do now
Set geometry.dynamic = true;
Load the rest of the JSON files with plain old AJAX (alternatively you could combine the frame JSON files to one file, whatever so you have access to all of them through your own code)
For each frame, loop the new frame vertex position array (found in the JSON for each frame) and overwrite the coordinates of your existing geometry vertices (geometry.vertices[i].x = myframevertices[i][0]; etc...)
Set geometry.verticesNeedUpdate = true; and render the frame.
Again I'm just assuming that each JSON file has the same amount and order of faces/vertices, and only the vertex positions change in each frame. I'm not completely sure if it works like that.
There has also been some (experimental?) work on BVH support with Three.js. You might have success searching around, I don't know if there is anything usable though. One related effort here: https://github.com/akjava/BVH-Motion-Creator