cocos2dx-lua 圆周运动

cocos2dx-lua 圆周运动_第1张图片

 描述:图片围绕着圆做圆周运动,一开始小鸟图片要放在圆中心位置

self.pic:stopAllActions()
    local cirCleR = 200 --圆的直径
    local dir = -1  --1逆,-1顺
    local x = 0
    local y = 0
    local beagainX  = self.pic:getPositionX()
    local beagainY  = self.pic:getPositionY()
    local convRtain = self.pic:getRotation() >= 360 and 1 or self.pic:getRotation()
    local function Run_Crile()
       x = beagainX + (math.cos(convRtain * 3.14 / 180) * cirCleR) 
       y = beagainY + (math.sin(convRtain * 3.14 / 180) * cirCleR) 
       -- self.pic:setRotation(90-convRtain)
       self.pic:setPosition(x ,y )
       convRtain = convRtain >= 360 and 1  or convRtain + 1 * dir
    end
    local cfun = cc.CallFunc:create(Run_Crile)
    local ccSequencde = cc.Sequence:create(cfun)
    self.pic:runAction(cc.RepeatForever:create(ccSequencde))

你可能感兴趣的:(cocos2dx-lua,cocos2d,lua)