xiemakeinu Posted June 20, 2014 Report Share Posted June 20, 2014 Hello all. I wanted to implement Spriter into Cocos2d-x 2.2.2, so I scoured these forums and the internet, but wasn't too happy with the results. Generic C++ implementations and old Cocos2d-x implementations that weren't really set up to do things the "Cocos2d-x" way, meaning they weren't fully utilizing the CCNode hierarchy for transforms. I'm still working on this thing, but I wanted to go ahead and share it in its current state. Simple sprite and bone animations are functional: translation, rotation, scale, and colorizing. Please note that some of the files in the attached archive need to be merged into the existing engine code. Also, for some reason unbeknownst to me, Cocos2d-x is set up to use reversed rotations(positive being clockwise), which I decided to change at the core level of the engine. Obviously this could break a lot of the built in tools, so some of you may want to just inverse the rotations in the Spriter implementation instead. You can use this implementation like you do anything else in Cocos2d-x: CCSpriter* spriterTest = CCSpriter::create("anim/player/Player.scml"); spriterTest->setPosition(CCPointMake(512.0f, 384.0f)); addChild(spriterTest, 5); My future plans for this are: [*:1jditbpz]Add support for zindex[*:1jditbpz]Add support for parent swapping[*:1jditbpz]Add support for texture swaps(may already work, needs testing)[*:1jditbpz]Add support for default file defined pivots[*:1jditbpz]Add support for adding/removing sprites and bones during animation[*:1jditbpz]Add support for plists Not sure how much further I'm going to go with it beyond that, but this should lay a good groundwork for someone to make it "fully featured". Because this is loosely based on work done by BruceWang and 568083142 on this forum, which was based on work done by James Hui (a.k.a. Dr.Watson), I've stuck with the BSD License. CCSpriter.zip UElabeal 1 Quote Link to comment Share on other sites More sharing options...
xiemakeinu Posted June 22, 2014 Author Report Share Posted June 22, 2014 Well, supporting a number of those features actually went by pretty quickly. I don't plan on improving this for the next few weeks/months, except for any bugs that need fixing. The only thing from my list that I haven't implemented is the Plists support, as I'm not going to need that for a while. Here's a list of what I have done: [*:6jyn9yxw]Added support for z index changes[*:6jyn9yxw]Added support for parent changes[*:6jyn9yxw]Added support for default file defined pivots[*:6jyn9yxw]Added support for adding/removing sprites and bones during animation[*:6jyn9yxw]Added support for nodes without animation[*:6jyn9yxw]Added memory cleanup on destroy If you encounter any bugs, please let me know. Also, if you could attach an example SCML file that exemplifies the bug, I'll do my best to fix it quickly. CCSpriter.zip Quote Link to comment Share on other sites More sharing options...
kaseru Posted October 6, 2014 Report Share Posted October 6, 2014 Hello. Thanks for sharing. Can you convert for cocos2d-x version 3.x ??? Quote Link to comment Share on other sites More sharing options...
Kiori Posted January 11, 2015 Report Share Posted January 11, 2015 If you also need this to be officially supported by cocos2d-x team, please post here:http://discuss.cocos2d-x.org/t/spriter-cocos2dx-support/7111 Quote Link to comment Share on other sites More sharing options...
xiemakeinu Posted March 20, 2016 Author Report Share Posted March 20, 2016 If anyone is searching for the original zip file, I've uploaded a copy of the code to http://www.greatergoodgames.org/CCSpriter.zip Quote Link to comment Share on other sites More sharing options...
ilunga Posted May 4, 2016 Report Share Posted May 4, 2016 I think it's a misprint spriter/CCSpriterKey.cpp CCSpriterTimelineVisualKey* CCSpriterTimelineVisualKey::create(XMLNode* node, int& index) { ... if (objectElement->QueryFloatAttribute("pivot_y", &floatValue) == XML_SUCCESS) key->m_vecPivot.y = floatValue; else key->m_vecPivot.x = -9000.0f; // <--------------- line 206 } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.