CG.AtlasTexturePacker Class
CG.AtlasTexturePacker class supports loading xml and json files from . . . TexturePacker ;o) No trimming at the moment, keep TexturePacker settings simple! The rotation option of TexturePacker will be dropped in future releases! AtlasTexturePacker parses xml/json and generates new CG.AtlasImage objects in the MediaAsset manager. These atlasimages are only handled within Sprite, Particle and Button class.
// Preloader
Game.asset.addImage('media/img/texturepacker.png', 'texturepacker') // image of texturepacker
.addXml('media/img/texturepacker.xml', 'texturepacker-xml') // xml version of texturepacker
.addJson('media/img/texturepacker.json', 'texturepacker-json') // json version of texturepacker
.startPreLoad()
// create texturepacker object
var tp = new CG.AtlasTexturePacker()
// load texturepacker json file
tp.loadJson(Game.asset.getJsonByName('texturepacker-json'))
// or load texturepacker xml file
//tp.loadXml(Game.asset.getXmlByName('texturepacker-xml'))
// add images of texturepacker to Game.asset
Game.asset.images.push.apply(Game.asset.images, tp.getAtlasImages())
Item Index
Methods
Properties
Methods
getAtlasImages
()
Array
get all TexturePacker images (Use array.push.apply(array, anotherarray) to append to Game.asset)
Returns:
returns all atlasimages of TexturePacker file to use with Game.asset
init
()
Returns:
loadJson
-
jsonfile
load a json file from TexturePacker
Parameters:
-
jsonfile
String/objectpath or mediaasset object with data of TexturePacker json
Returns:
loadXml
-
xmlfile
load a xml file from TexturePacker
Parameters:
-
xmlfile
String/objectpath or mediaasset object with data of TexturePacker xml