加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

cocos2dlua-动画

发布时间:2020-12-14 16:30:31 所属栏目:百科 来源:网络整理
导读:通过texture创建动画 图片纹理+矩形精灵框架1+精灵框架2动画动作 -- create dog animate local textureDog = cc .Director :getInstance():getTextureCache():addImage( "dog.png" ) local frameWidth = 105 local frameHeight = 95 local rect = cc .rect (

通过texture创建动画
图片>纹理+矩形>精灵框架1+精灵框架2>动画>动作

-- create dog animate
    local textureDog = cc.Director:getInstance():getTextureCache():addImage("dog.png")
    local frameWidth = 105
    local frameHeight = 95
    local rect = cc.rect(0,0,frameWidth,frameHeight)
    local frame0 = cc.SpriteFrame:createWithTexture(textureDog,rect)
    rect = cc.rect(frameWidth,frameHeight)
    local frame1 = cc.SpriteFrame:createWithTexture(textureDog,rect)

    local spriteDog = cc.Sprite:createWithSpriteFrame(frame0)
    spriteDog:setPosition(self.origin.x,self.origin.y + self.visibleSize.height / 4 * 3)
    spriteDog.isPaused = false

    local animation = cc.Animation:createWithSpriteFrames({frame0,frame1},0.5)
    local animate = cc.Animate:create(animation);
    spriteDog:runAction(cc.RepeatForever:create(animate))

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读