SpriteSheet data from XML like AtlasTexture Starling

Software: Away3D 4.x

luckypig, Newbie
Posted: 02 July 2013 05:18 PM   Total Posts: 10

Hi.

I’m new in the forum, you do a great work with this.

I’m developing a game with Away3d and Starling and I have a important question about SpriteSheet.

There are any method for parse the Texture of the SpriteSheet with the data from a XML like AtlasTexture in Starling?

I want to use the SpriteSheet for textured all my meshes, but I don’t know how parse the nodes with the data XML automatically.

I hope your comments.

Regards! Thanks.

   

Avatar
Fabrice Closier, Administrator
Posted: 02 July 2013 10:46 PM   Total Posts: 1265   [ # 1 ]

because there is still a todo for one last thing to support atlases it is not yet added to the api.

This for instance will accept atlasses, but will not work for compressed atlases.
Unlike Starling and probably other 2d api’s, we do not work with quads and build a 9 grid like for these cases. Because we apply on unknown geometry, we need handle the reconstruct of missing space via agal. Which is still on the todo.

In meanwhile, you can add this very early version of the method to tools.SpriteSheetHelper.as.

If you (have) follow(ed) the tutorials, that should make sens.

public function parseAtlasXml(animID:String, textureWidth:uint, textureHeight:uint, atlasXml:XML) : SpriteSheetAnimationSet
  {
  var spriteSheetAnimationSet:SpriteSheetAnimationSet = new SpriteSheetAnimationSet();
  var node:SpriteSheetClipNode = new SpriteSheetClipNode();
  node.name = animID;

  spriteSheetAnimationSet.addAnimation(node);

  var frame:SpriteSheetAnimationFrame;
  var u:uint, v:uint,i:uint;

  var scale:Number = 1;//mAtlasTexture.scale;

  for each (var subTexture:XML in atlasXml.SubTexture)
  {
  var name:String = subTexture.attribute(“name”);
  var x:Number = parseFloat(subTexture.attribute(“x”)) / scale;
  var y:Number = parseFloat(subTexture.attribute(“y”)) / scale;
  var width:Number = parseFloat(subTexture.attribute(“width”)) / scale;
  var height:Number = parseFloat(subTexture.attribute(“height”)) / scale;
  //  var frameX:Number = parseFloat(subTexture.attribute(“frameX”)) / scale;
  //  var frameY:Number = parseFloat(subTexture.attribute(“frameY”)) / scale;
  //  var frameWidth:Number = parseFloat(subTexture.attribute(“frameWidth”)) / scale;
  //  var frameHeight:Number = parseFloat(subTexture.attribute(“frameHeight”)) / scale;

  //  var regionR:Rectangle = new Rectangle(x, y, width, height);
  // var frameR:Rectangle = frameWidth > 0 && frameHeight > 0 ? new Rectangle(frameX, frameY, frameWidth, frameHeight) : null;


  frame = new SpriteSheetAnimationFrame();
  frame.offsetU = x / textureWidth;
  frame.offsetV = y / textureHeight;
  frame.scaleU = width / textureWidth;
  frame.scaleV = height / textureHeight;
  frame.mapID = i;

  node.addFrame(frame, 16);
  i++;
  }

  return spriteSheetAnimationSet;
  }

   

luckypig, Newbie
Posted: 03 July 2013 08:41 AM   Total Posts: 10   [ # 2 ]

Thanks a lot!

I’m going to test it.

When I have the results I give you feedback.

If you end a new version of the method could you post it?

Regards.

   

Mario M., Newbie
Posted: 23 August 2013 11:40 AM   Total Posts: 12   [ # 3 ]

Any news about AtlasTextures?

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X