-- 组件行为基础 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;