该函数只适用于cocos2dx 2.2.5
--创建帧动画 --[[ FrameWidth 帧动画宽 FrameHeight 帧动画高 imageFile 图片文件 默认循环播放 ]]-- local function createAnim(FrameWidth,FrameHeight,imageFile) local tex = CCTextureCache:sharedTextureCache():addImage(imageFile) frame0 = CCSpriteFrame:createWithTexture(tex,CCRectMake(0,FrameWidth,FrameHeight)) frame1 = CCSpriteFrame:createWithTexture(tex,CCRectMake(FrameWidth*1,FrameHeight)) local spriteDog = CCSprite:createWithSpriteFrame(frame0) spriteDog:setPosition(CCPoint(100,100)) spriteDog:setVisible(true) animFrames = CCArray:createWithCapacity(2); animFrames:addObject(frame0); animFrames:addObject(frame1); animation = CCAnimation:createWithSpriteFrames(animFrames,0.5) animate = CCAnimate:create(animation); spriteDog:runAction(CCRepeatForever:create(animate)) return spriteDog end
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。