Giter Site home page Giter Site logo

spriter2moai's Introduction

Spriter to Moai

Spriter SCML to Moai generator. This library allows you to import animations created using BrashMonkey Spriter (http://www.brashmonkey.com/spriter.htm) and use them in Moai (http://gemoai.com)

Requirements:

  • This library assumes you are using a version older then Spriter a2 and currently does not support animations that make use of the new IK bones introduced in Spriter a4. This should be added shortly, the current work around is to create your animations and then create a copy of the project with all the bones deleted before exporting.
  • This library also requires the use of TexturePacker to generate the textures (with all sprite parts using consistent names with those used in Spriter and no folder prefixes in the TexturePacker generated lua files)

scml2moai.py

This python script is required to convert the CSML file into a lua file for use in Moai.

Usage:

> ./scml2moai.py -h

Usage: scml2moai.py file.scml [options]

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -f FILE, --file=FILE  specify output FILE (default outputs to same name as
                        scml file)
  -4, --x4              Dimensions are based on @4x size also output @2x.lua
                        and standard .lua files
  -2, --x2              Dimensions are based on @2x size also output standard
                        .lua files
  • -f - Use this option if you want to specify an output .lua filename (Default will use the same name as the scml file with a .lua extension)
  • -4 - Use this if you have generated your artwork for large resolution tablets and desktops and then used Texture Packer to create sizes for smart phones, tablets/retina iPhones (@2x extension) and HD tables screens (@4x extension). This creates three lua files. @4x.lua for use with full size artwork, @2x for use with 50% artwork and .lua for use with 25% size artwork.
  • -2 - Use this if you have generated your artwork for retina iPhones / SD tablets (@2x) and then used Texture Packer to create sizes for SD smart phones. *This creates two lua files. @2x for use with full size artwork and .lua for use with 50% size artwork.

lib/tpsloader.lua

Require this lua file for the logic to load in Texture Packer lua files, as provided within the Moai samples folder.

lib/spriter.lua

Require this lua file to load the scml2moai lua file generated by the script above (See main.lua for an example of usage). This file is based on the Flash Tween example provided in the Moai sample folder.

Assets and example files

The following files and folders contain the example scml file and assets as provided on the BrashMonkey on their site here http://www.brashmonkey.com/spriter.htm

  • example.scml (as well as example.lua generated by scml2moai.py above)
  • mon_arms
  • mon_head
  • mon_legs
  • mon_shadow
  • mon_torso

The following files were generated by Texture Packer

  • monster.lua (Lua texture map)
  • monster.png (texture file)
  • monster.tps (Texture Packer project file)

Licence

These files unless specified in the source header are distributed under the MPL-2.0 licence (http://opensource.org/licenses/MPL-2.0)

spriter2moai's People

Contributors

miletbaker avatar lyleunderwood avatar

Stargazers

Marco Gallo avatar  avatar arek_wojcieszek avatar Alexandru Badiu avatar Dorian Cussen avatar makoto avatar Steven Johnson avatar Sung Ahn Kim avatar Jonathan Shieh avatar

Watchers

 avatar arek_wojcieszek avatar Stuart Nicholson avatar  avatar

spriter2moai's Issues

Pivots not working

When an animation modifies the sprite pivot, the script doesn't parse it correctly. If I have time, I will upload a sample of this.

looping attribute must be set to 'false' for animations

I've noticed that the script falls over when trying to parse a scml file that has an animation defined without the 'looping' attribute.

It appears that Spriter will export the animation without the looping attribute when looping is set to true. (I'm using version b2, I'm not sure if this is the case with older versions)

As a workaround, I turned off looping on all my animations

The troublesome line of code appears to be line 45 in scml2moai.py
loop = False if attrs.getValue('looping') == 'false' else True

The error output from python is as follows:
Traceback (most recent call last):
File "./scml2moai.py", line 203, in
main()
File "./scml2moai.py", line 185, in main
xml.sax.parse (inpath, handler)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/init.py", line 33, in parse
parser.parse(source)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
self.feed(buffer)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/expatreader.py", line 207, in feed
self._parser.Parse(data, isFinal)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/expatreader.py", line 301, in start_element
self._cont_handler.startElement(name, AttributesImpl(attrs))
File "./scml2moai.py", line 49, in startElement
loop = False if attrs.getValue('looping') == 'false' else True
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xml/sax/xmlreader.py", line 291, in getValue
return self._attrs[name]
KeyError: 'looping'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.