* [Corona] Adding ability to load atlas files * [Corona] Added example of using atlas # Documentation: ## Lua runtime: `spine.Atlas.parse` `Atlas.lua` introduces `spine.Atlas.parse(atlasPath, baseDir)` funciton. This function can be use across Lua runtimes to implement their their own image sheet bindings. It will return Array of `Page`s or `nil` if error. ### `Page` properties: * `name` - filename of the page (`"raptor.png"`) * `size` - dimmensions of original image (`[1022,1022]`) * `format` - texture format (`"RGBA8888"`) * `filter` - filter for texture scalin up and down (`["Linear","Linear"]`) * `wrap` - wrap modes (`"none"`) * `regions` - Array of `Region`s on this page ### `Region` properties: * `name` - region name (`"torso"`) * `rotate` - is image rotated in texture (`true`) * `xy` - image frame position on texture (`[610,647]`) * `size` - image frame size on texture (`[54,91]`) * `splits` - (optional) * `pad` - (optional) * `orig` - original image size (`[54,91]`) * `offset` - offset if image was trimmed (`[0,0]`) * `index` - `-1` ## Corona runtime: `spine.GetAtlasSprites` `spine.lua` introduces `spine.GetAtlasSprites(atlasName, baseDir)`, which returns `Sprites` table. This funciton would parse atlas, locate atlas textures, load them to Corona's image sheets and create convinience bindings and functions. User can use convenience functions, or write own wrappers. ### `Sprites` table #### Convenience functions: * `ATLAS_HELPER_createImage` - can be assigned to `skeleton.createImage` * `ATLAS_HELPER_createMesh` - can be assigned to `skeleton.createMesh` * `ATLAS_HELPER_setupSkeleton` - use this on skeleton to assing both creation functions (`sprites.setupSkeleton(skeleton)`) ### Region name bindings: All other elements of `Sprites` table would contain binding `sprites["region_name"] = sheetReference`, where each `sheetReference` contains following elements: * `frame` - number of frame in image sheet (`42`) * `region` - reference to `Region` table * `page` - reference to `Page` table. `Page` table would also get new property - `sheet`, reference to Corona's image sheet where sprites can be accessed. As result, to create image for `attachment` code would look something like `display.newImage( sprites[attachment.name].page.sheet, sprites[attachment.name].frame )`. For more rubust example see `ATLAS_HELPER_createImage` in `spine-corona/spine.lua`. # Known Issues: * Corona would not work with padded/cropped atlases. * Possible (but unprobable) name collision with region names and `ATLAS_HELPER_*` functions.
spine-corona
The spine-corona runtime provides functionality to load, manipulate and render Spine skeletal animation data using Corona. spine-corona is based on spine-lua.
Licensing
This Spine Runtime may only be used for personal or internal use, typically to evaluate Spine before purchasing. If you would like to incorporate a Spine Runtime into your applications, distribute software containing a Spine Runtime, or modify a Spine Runtime, then you will need a valid Spine license. Please see the Spine Runtimes Software License for detailed information.
The Spine Runtimes are developed with the intent to be used with data exported from Spine. By purchasing Spine, Section 2 of the Spine Software License grants the right to create and distribute derivative works of the Spine Runtimes.
Spine version
spine-corona works with data exported from Spine 2.1.27. Updating spine-corona to v3.0, v3.1, v3.2, and v3.3 is in progress.
spine-corona supports all Spine features except for rendering meshes due to Corona having a limited graphics API.
spine-corona does not yet support loading the binary format.
Setup
- Download the Spine Runtimes source using git or by downloading it as a zip.
- Copy the contents of
spine-luatospine-corona/spine-lua. - Run the
main.luafile using Corona. There are multiple examples that can be enabled by editing this file.
Alternatively, the spine-lua and spine-corona/spine-corona directories can be copied into your project. Note that the require statements use spine-lua.Xxx, so the spine-lua files must be in a spine-lua directory in your project.