8 mobile game development artifact cocos2d-x editor animation and Frame Animation

Source: Internet
Author: User

The success of a game depends largely on the success of the animation. Readers familiar with cocos2dx know that it has many ready-made animations. In this section, I will make little monsters move forward slowly;


The running effect is as follows:





Code: http://www.kuaipan.cn/file/id_25348935635744616.htm? Source = 1



Create a New frame animation file, named "Resorces ----- New ---- FramesAnimation", and create the snow_frame.plish file.


<喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + pgltzybzcm9 "http://www.2cto.com/uploadfile/Collfiles/20140125/2014012509104397.jpg" width = "700" height = "400" alt = "\">


The installation operation creates a set of frames and can be adjusted and modified in the xml file;



After the image is created successfully, use the first frame in the image as the sprite to create and adjust the parameters.




Open MainLayer. js and write the code as follows:

//// CleanerScoreScene class // var MainLayer = function () {cc. log ("MainLayer") this. scoreLabel = this. scoreLabel | {}; this. monster = this. monster | {}; this. score = 123 ;}; MainLayer. prototype. onDidLoadFromCCB = function () {if (sys. platform = 'browser ') {this. onEnter ();} else {this. rootNode. onEnter = function () {this. controller. onEnter () ;};} this. rootNode. schedule (function (dt) {this. controller. onUpdate (dt) ;}); this. rootNode. onExit = function () {this. controller. onExit () ;};}; MainLayer. prototype. onEnter = function () {cc. animationCache. getInstance (). addAnimations ("Resources/snow_frame.plist"); // Add the Frame Animation file var action0 = cc. sequence. create (cc. moveTo. create (30, cc. p (360,200); // move var actionFrame = cc forward. animate. create (cc. animationCache. getInstance (). getAnimation ("monster"); // get the Frame Animation var action1 = cc. repeat. create (actionFrame, 90000); var action2 = cc. spawn. create (action0, action1); // synchronize the animation this. monster. runAction (action2);} MainLayer. prototype. onUpdate = function (dt) {this. score + = dt; this. scoreLabel. setString (Math. floor (this. score);} MainLayer. prototype. onExitClicked = function () {cc. log ("onExitClicked");} MainLayer. prototype. onExit = function () {cc. log ("onExit");} cc. animate. createWithName = function (name) {return cc. animate. create (cc. animationCache. getInstance (). getAnimation (name ));}


In the next article, I will introduce the particle effect of cocos2d-x editor)

Source: cocos2d-x editor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.