cocos2dx-Action-圆周运动

if srpite == nil then return end 
srpite:stopAllActions()
local cfg = cfg or {}
local cirCleR = cfg.cir or 50 
local dir = dir or 1
local x = 0
local y = 0
local  beagainX  = bX or srpite:getPositionX()
local  beagainY  = bY or srpite:getPositionY()
local convRtain = srpite:getRotation() >= 360 and  1 or srpite:getRotation()
local function Run_Crile()
       x = beagainX + (math.cos(convRtain * 3.14 / 180) * cirCleR) 
       y = beagainY + (math.sin(convRtain * 3.14 / 180) * cirCleR) 
       srpite:setRotation(90-convRtain)
       srpite: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)
    srpite:runAction(cc.RepeatForever:create(ccSequencde))

你可能感兴趣的:(cocos笔记本-个人)