动画与动作,在quick中都有对其封装,所以我们还是来看一下吧。
总的来说,对于帧动画,quick封装的方法我们可以经常使用,这是非常方便的,下面直接上代码来直观感受下,
比如,14张帧图片,采用cocos2d-x lua的方法来写是这样的,
- localsp=display.newSprite(@H_403_21@"grossini_dance_01.png"@H_403_21@,display.cx,display.cy)@H_403_21@@H_403_21@
- self:addChild(sp)@H_403_21@
- @H_403_21@
- localanimation=CCAnimation:create()@H_403_21@
- localnumber,name@H_403_21@
- for@H_403_21@i=1,14@H_403_21@do@H_403_21@@H_403_21@@H_403_21@
- if@H_403_21@i<10then@H_403_21@@H_403_21@
- number="0"@H_403_21@..i@H_403_21@@H_403_21@
- else@H_403_21@@H_403_21@@H_403_21@
- number=i@H_403_21@
- end@H_403_21@
- name="grossini_dance_"@H_403_21@..number..@H_403_21@".png"@H_403_21@@H_403_21@@H_403_21@
- animation:addSpriteFrameWithFileName(name)@H_403_21@
- end@H_403_21@
- animation:setDelayPerUnit(2.8/14.0)@H_403_21@
- localaction=CCAnimate:create(animation)@H_403_21@
- sp:runAction(action)@H_403_21@
需要将其每一帧添加到CCAnimation中,和C++使用是一样的,但是quick的用法就是这样子的了,@H_403_21@
[html]
copy