Tried to get it to work again, compiles but gives:
http://i.imgur.com/ujGY9mw.png
Running the SWF from the bin folder:
http://i.imgur.com/MI3W2Qm.png
Attached is the project.
Help wth Spine and Starling AssetManager
I installed FB4.6
Here are 2 FB4.6 Actionscript Mobile projects.
https://dl.dropboxusercontent.com/u/957 ... AIR3.5.zip
** Please Note these use Flex 4.6 with Air 3.5, 3.4 should work just remember to change the Main-app.xml descriptor.
Your project was set to AIR3.1, Starlings minimum version is Air 3.4 /FP 11.4 but recommends the latest SDKs and players
I use AIR 14 ASCompiler 2.0 with Stage 3D, it's incredibly fast on mobile and desktop.
Here is a Windows Flash Projector as a backup so you can at least see the animation when you click on it
https://dl.dropboxusercontent.com/u/957 ... jector.zip
This is what works right now in SpineSimple and should be exactly the same with the Starling AssetManager.
I hope this helps
Thanks again
- Patrick
Hello,
I cannot recall from memory to give u a code snippet which would work right away. But I can give u a hint:
I can see your atlas file has the extension *.atlas. So I assume this atlas was generated by Spine. The Format of this atlas file is different than the xml which Starling / Sparrow expects. So assetManager.getTextureAtlas() will not work. My guess is it will return "null".
Instead I would try "new Atlas( sAssets.getByteArray("p2-wind-atlas") , new StarlingTextureLoader( sAssets.getTexture("p2-wind-sleleton") ) );", if the Atlas class take byteArrays. Otherwise try "sAssets.getByteArray("p2-wind-atlas").readUTF()" instead.
Another way would be to pack the texture atlas with something else than Spine (e.g. TexturePacker). Than u can use assetManager.getTextureAtlas() again. This is what I do.
PS: Answered you on the Starling forum as well
Cheers
Thanks Matulk, your idea worked. I am so grateful...I hope someone else finds this useful. Its huge for me.
I repacked the texures with TexturePacker and then only loaded the json output from Spine.
var json : SkeletonJson = new SkeletonJson( new StarlingAtlasAttachmentLoader( sAssets.getTextureAtlas( "spine-texture" ) ) );
var skeletonData : SkeletonData = json.readSkeletonData( sAssets.getObject( "spine-json" ) );
var stateData : AnimationStateData = new AnimationStateData( skeletonData );
spine-texture is (xml and png) from TexturePacker
spine-json is (skeleton json) from Spine
awesome!
** btw I also updated my spine.starling.SkeletonSprite with this:
polygonBatch.add(image.texture, worldVertices, verticesLength, uvs, triangles, r, g, b, a, slot.data.additiveBlending, matrix);
to this
polygonBatch.add(image.texture.root, worldVertices, verticesLength, uvs, triangles, r, g, b, a, slot.data.additiveBlending, matrix);
See this reference:
viewtopic.php?f=7&t=3193
This reduced my Draw Calls amazingly...26 to 1 !!! WOW!
Thanks again Matulk you've really made my week!
- Patrick
this post should mark as sticky post or included in https://github.com/EsotericSoftware/spi ... /src/spine as an example.
As new Spine-Starling user, it's take me a couple days to find out how to manage Spine as Asset in Starling.
Everyone from as3 use Starling (Stage3D) for optimation, right?
i hope in the future, Spine will have "Starling" as an option when exporting atlas..
thanks matulk for pointed it out that Spine's atlas is different than the xml which Starling expects.
And thanks retropunk for sharing, you all saved my day
An asset loader example is a good idea. Maybe you have an example to post here, or send a PR?
this is example about how to use AssetManager.as
http://wiki.starling-framework.org/manu ... management
i'm still can't find clear solution about how to use Starling's AssetManager with Spine-Starling runtime.
Instead of use TexturePacker, i'd like to use the original Spine's export format. (tight for TexturePacker lol XP)
still trying..
i think it's not a good idea to ask Starling manage Spine's assets
http://forum.starling-framework.org/topic/assetmanager-for-spine
but, since atlas and Texture in Spine and Starling quite different, i think i need make a new AssetManager to manage both starling's and spine's assets.
this's some code i make by using singleton to make easier access the game's assets.
Assets.as
package
{
import flash.utils.Dictionary;
import spine.atlas.Atlas;
import spine.attachments.AtlasAttachmentLoader;
import spine.attachments.AttachmentLoader;
import spine.SkeletonData;
import spine.SkeletonJson;
import spine.starling.StarlingTextureLoader;
import starling.textures.Texture;
import starling.utils.AssetManager;
/**
* ...
* @author zain
*/
public class Assets extends AssetManager
{
private static var instance:Assets;
private static var _assets:AssetManager;
private static var mSkeletonData:Dictionary;
public function Assets(singleton:SingletonEnforcer):void {
_assets = new AssetManager();
mSkeletonData = new Dictionary();
}
/** instance checker */
private static function tryinit():void {
if ( instance == null ) instance = new Assets( new SingletonEnforcer() );
}
[i]public static function enqueue(...rawAssets):void {
tryinit();
_assets.enqueue(rawAssets);
}
public static function loadQueue(onProgress:Function):void {
tryinit();
_assets.loadQueue(onProgress);
}
public static function getTexture(name:String):Texture {
return _assets.getTexture(name);
}[/i]
//{ === region: Spine Assets ===
public static function loadSkeletonData(name:String, textureClass:Class, atlasClass:Class, jsonClass:Class ):void {
tryinit();
if (name in mSkeletonData) {
}else{
var textureLoader:StarlingTextureLoader = new StarlingTextureLoader(new textureClass());
var spineAtlas:Atlas = new Atlas(new atlasClass(), textureLoader);
var attachmentLoader:AttachmentLoader = new AtlasAttachmentLoader(spineAtlas);
var json:SkeletonJson = new SkeletonJson(attachmentLoader);
mSkeletonData[name] = json.readSkeletonData(new jsonClass());
}
}
public static function getSkeletonData(name:String):SkeletonData {
return mSkeletonData[name];
}
//} === endregion: Spine Assets ===
}
}
class SingletonEnforcer
{
//nothing
}
just focus on Spine Assets region.
i'm not use the starling's AssetManager part yet.
this is some test about the SkeletonData part and how to use my Asset's manager
skeleton = new SkeletonAnimation(Assets.getSkeletonData("april"), true);
skeleton.x = 400;
skeleton.y = 560;
skeleton.state.setAnimationByName(0, "walk", true);
skeleton2 = new SkeletonAnimation(Assets.getSkeletonData("april"), true);
skeleton2.x = 800;
skeleton2.y = 560;
skeleton2.state.setAnimationByName(0, "run", true);
addChild(skeleton);
addChild(skeleton2);
Starling.juggler.add(skeleton);
Starling.juggler.add(skeleton2);
and the managed spine's SkeletonData result show nice draw call (only 1 draw call)
i hope this useful :coffee:
Hi Zain, I have been using Spine for my animation data (JSON) and then I use TexturePacker to consolidate my assets XML + PNG/ATF spritesheets).
I use Starlings AssetManager too. It took a few tries to get it working the way I wanted but it's currently working very well.
I'm sure it would be more straight forward to use the ATLAS export from Spine but I actually prefer TexturePacker. TexturePacker gives me the control I need when dealing with TONS of assets. I can export different asset types easily depending on the platform like mutiple ATF types, which is important to my production needs.
When it comes to Starling/Spine projects there hasn't been too much noise on the forums so I'd be happy to share some code if you still need it.
- Patrick
Hi retropunk,
thanks for comeback to this thread again :happy:
as new learner in Spine-Starling, of course i (maybe us*) would like to see your resolved code after using TexturePacker for centralized AssetManager (starling.utils.AssetManager). And i'm sure the TexturePacker mentioned here is not TexturePacker from Spine, right? (just for make sure).
Yes, i knew the TexturePacker commonly used by starling's user.
Just one thing that i really want to know if i use TexturePacker is: is it still possible to use "Meshes" and "Free-form Deformation" feature from Spine in Starling's runtimes?
So, sure i really would like to see your code
i want to compare it
:very excited :rofl: :
thank before~
*) us
see your thread is viewed 2544 times[/i]
[SOLVED for Atlas (no XML) way & No Starling Scaling used]
This way works and you can use the SPINE ATLAS, no need to repack the texture in another program. I needed this and tried this 5 minute ago and it 100% works! By default the spine atlas gets loaded as a byteArray in Starling AssetManager. So just use this code:
// Important Parts:
// assets.getByteArray("spineboy") // Atlas file
// assets.getTexture("spineboy") // PNG file
// assets.getObject("spineboy") // JSON file
// MAKE SURE TO CREATE AN ASSET MANAGER FIRST AND LOAD THESE IN
var attachmentLoader:AttachmentLoader;
var spineAtlas:Atlas = new Atlas(assets.getByteArray("spineboy"), new StarlingTextureLoader(assets.getTexture("spineboy"))); // (atlas, texture)
attachmentLoader = new AtlasAttachmentLoader(spineAtlas);
var json:SkeletonJson = new SkeletonJson(attachmentLoader);
var skeletonData:SkeletonData = json.readSkeletonData(assets.getObject("spineboy")); // json file
skeleton = new SkeletonAnimation(skeletonData);
skeleton.x = 320;
skeleton.y = 420;
skeleton.skeleton.setSlotsToSetupPose();
skeleton.state.setAnimationByName(0, "walk", true);
addChild(skeleton);
Starling.juggler.add(skeleton);
NOTE: If the assetManager has a scale set to it then the spine texture (PNG) comes in at the wrong size (See XML way below).
[SOLVED: XML WAY]
If your project does use scale, I think it's actually quicker and faster (processing wise) to just use the XML option. 2 steps.
1) Create a spritesheet of your Spine images in ShoeBox or TexturePacker (the non-Spine one)
2) With the attachmentLoader, just use the Atlas (png+xml) that the Starling assetManager creates.
Example:
var attachmentLoader:AttachmentLoader;
attachmentLoader = new StarlingAtlasAttachmentLoader(assetsgetTextureAtlas("spineboy")); // The Atlas Starling's assetManager created
var json:SkeletonJson = new SkeletonJson(attachmentLoader);
var skeletonData:SkeletonData = json.readSkeletonData(assetsgetObject("spineboy")); // json file
skeleton = new SkeletonAnimation(skeletonData);
skeleton.skeleton.setSlotsToSetupPose();
skeleton.state.setAnimationByName(0, "walk", true);
addChild(skeleton);
Starling.juggler.add(skeleton);
Anybody is capeable of wirting a sub class of AttachmentLoader: StarlingAssetManagerLoader
I often have a mixture of quite a few assets. Some animation assets some other. Also they distibute over a few texture atlases.
Of course that class would also compensate for the scaling of the textures.
var json:SkeletonJson = new SkeletonJson(new StarlingAssetManagerLoader(myAssetManager));
Would that be possible?