newlist

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
-- 组件行为基础
local Behavior = class("Behavior"); 

function Behavior:ctor(name)
    self.owner = nil;
    self.name = name;
    self.id = getNextID();
    self.isOk = false;
end

function Behavior:getGameObject( )
    return self.owner;
end

function Behavior:setGameObject(owner)
    self.owner = owner;
    self.isOk = true;
end

function Behavior:getName( )
    return name;
end

function Behavior:deltaTime(  )
    return CCDirector:sharedDirector():deltaTime();
end

function Behavior:performWithDelay(callback, delay)
    if (self.isOK == false) then
        echoError("Behavior init after addComponet") 
        return;
    end
    
    local action = Transition.sequence({
        CCDelayTime:create(delay),
        CCCallFunc:create(callback),
    })

    self.owner:runAction(action)
    return action
end

return Behavior;

 

posted on 2014-04-16 10:42  一枚程序  阅读(3469)  评论(0编辑  收藏  举报