Cocos2dx plays flash animation

Cocos2dx plays flash animation


Cocos2dx plays flash animation)

Original text:Cocos2dx plays flash animation
Let’s start with the recent work, which I remember most clearly.

Anyone who makes game client programs knows that animation production is a very time-consuming and laborious task. Let’s first list a few commonly used animation methods: using animations supported by the underlying engine (such as movement, zooming in, etc.), frame animation and particle animation. Cocos2dX's support for animation is relatively simple, and you generally have to write whatever you want to use yourself. This reminds me of Flash, a very classic and easy-to-use animation production software. Is there a way to make Flash used by Cocos2dx.

After a series of searches and attempts, I suddenly found a very useful tool: Super Animation Conv. The name sounds very domineering, but also quite vulgar. This software is open source, so you can use it with confidence. After using it, I couldn't put it down. I recommended it to my colleagues and it was well received and greatly improved my work efficiency. What makes me admire even more is that this software is the work of Chinese engineers like us. Next, let’s introduce the uses of the tools. I also do a job of exporting to domestic sales. Help you with some translation work.

In short, this tool allows your game to completely eliminate frame animation. Compared with frame-by-frame animation, this method saves resources (pictures and memory) and eliminates a lot of tedious work in the program. First, the animator edits the required animation in Flash. He can use the functions of moving, scaling or rotating and reversing Flash objects. After exporting to a SWF file, use the Super Animation Converter tool that comes with the tool (supports both Windows and Mac) to export the animation description file Sam file and all picture materials used in the animation. Finally, the program appeared.

You can find several classes in the sample code that comes with the tool. As long as you import these classes into the game project, you can use the Sam resources obtained in the previous step. Here’s an Example:

std::string anAnimFileFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(“Sample.sam”);
SuperAnimNode* mAnim = SuperAnimNode::create(anAnimFileFullPath, 0, this);
addChild(mAnim);
mAnim->setPosition(ccp(aScreenSize.width * 0.5f, aScreenSize.height * 0.5f));
mAnim->PlaySection(“fade”);

Just like that, the animation named fade produced by the animation will play.

In actual application, some people will ask how to monitor the progress of animation, such as needing to play a certain sound effect at a certain moment, or wanting to process some game logic after the animation is played. It doesn’t matter, the tool provides a listening interface:

class SuperAnimNodeListener
{
public:
virtual void OnAnimSectionEnd(int theId, std::string theLabelName){}
virtual void OnTimeEvent(int theId, std::string theLabelName, int theEventId){}
};

Personally, I feel that the second interface OnTimeEvent is sufficient and can include the functions of the first interface. The reason is as follows. When registering the listener, theTimeFactor parameter must be added to indicate the time when the event is triggered. This time is a percentage parameter, from 0 to 1 indicating the start and end of the animation respectively.

// for time event
// theTimeFactor is in [0.0f, 1.0f],
// theTimeFactor = 0.0f means the event will be triggered at the first frame,
// theTimeFactor = 1.0f means the event will be triggered at the last frame
void registerTimeEvent(const std::string &theLabel, float theTimeFactor, int theEventId);

After talking about these basic usages, we finally invite the author:

Project on Github:https://github.com/raymondlu/super-animation-samples It contains code, forum and The address of the blog. Everyone is welcome to try it out. Another point to mention is that there are already several great tools using this set of tools, so the maturity level is relatively high and the reliability is also high. If you have any comments, please leave a message.


Author: When the Wind Rises Again 2013
Source: CSDN
Original text: https://blog.csdn .net/u012206807/article/details/11900661
Copyright statement: This article is an original article by the blogger. Please attach a link to the blog post for reprinting!

Guess you like

Origin blog.csdn.net/u012839224/article/details/86681524