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