quick-cocos2d-x教程13:实现帧动画

quick-cocos2d-x教程13:实现帧动画,第1张

概述帧动画是个常见功能,我把这个封装成一个函数。 --帧动画 function MainScene:newFrameAnimation()     display.addSpriteFramesWithFile("loading.plist", "loading.png")     local frames = display.newFrames("loading%04d.png", 0, 11)  

帧动画是个常见功能,我把这个封装成一个函数。

--帧动画

function MainScene:newFrameAnimation()

display.addSpriteFramesWithfile("loading.pList","loading.png")

local frames = display.newFrames("loading%04d.png",11)

local sprite = display.newSprite("#loading0000.png",display.cx,display.cy)

local animation = display.newAnimation(frames,0.8 / 11)

sprite:playAnimationForever(animation)


self:addChild(sprite)

end


然后调用:

function MainScene:ctor()

self:newFrameAnimation()

end


在实际使用中,可以新建一个层,然后把这个帧动画放到这个层里面。

function MainScene:newFrameAnimation()

local layer=display.newcolorLayer(ccc4(0,150)):addTo(self,1000)

layer:settouchEnabled(true)


display.addSpriteFramesWithfile("loading.pList",0.8 / 11)

sprite:playAnimationForever(animation)


layer:addChild(sprite)

end

总结

以上是内存溢出为你收集整理的quick-cocos2d-x教程13:实现帧动画全部内容,希望文章能够帮你解决quick-cocos2d-x教程13:实现帧动画所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1077430.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存