Light has the spirit is too rigid, the game must have a different animation, is the character moving around, a static figure can be sent to the game quality requirements more and more high players? So we're going to let the elves move.
Quick provides a function that uses sequence frame animation, which we can use directly.
The large image is now loaded into the cache and then extracted for use.
The main is the Display,newframes parameter, this kind of String.Format taste
@function [parent= #display] newframes--@param string pattern Strings--@param integer begin index--@param integer length --@param Whether Boolean isreversed is a descending index--@return table#table ret (return value:table) image frame Array
Be aware of your image name format when using it, such as your thing sprite001.png--sprite009.png, parameter is ("Srite%00d.png", 1,9)
function Mainscene:ctor () display.addspriteframes ("Lqfrolewalk.plist", "Lqfrolewalk.png") Local sprite = Display.newsprite ("#lqfDownStop. png") sprite:align (display. center,display.cx,display.cy) sprite:addto (self) sprite:setscale (2) Local frames = Display.newframes ("lqfdownwalk% D.png ",") Local animation = Display.newanimation (FRAMES,0.5/2) --0.5s inside play 2 frames Sprite:playanimationforever ( Animation) End
We see two pictures, the character foot changes (in fact, I was too lazy to intercept the dynamic map, haha haha, forgive my laziness)
But we can not use the time to create the animation bar, we may also before entering the scene, the required animation new, stored in the cache, when used to call the name directly
See the code below
function Mainscene:ctor () display.addspriteframes ("Lqfrolewalk.plist", "Lqfrolewalk.png") Local sprite = Display.newsprite ("#lqfDownStop. png") sprite:align (display. center,display.cx,display.cy) sprite:addto (self) sprite:setscale (2) Local frames = Display.newframes ("lqfdownwalk% D.png ",") Local animation = Display.newanimation (FRAMES,0.5/2) display.setanimationcache ("Lqfdownwalk", animation) Sprite:playanimationforever (Display.getanimationcache ("Lqfdownwalk")) end
We do this by storing an animation in the cache and then fetching it when it is needed.
Well, this is short, but can be rotated, oh, not yet rotated, the next one is writing! O (∩_∩) o
Quick Cocos2dx-lua (V3.3R1) Learning notes (vi)----Let the Elves move, use sequence frame animation