component/CCComponent (node接口函数 提供了serialize setEnabled setOwner接口 成员数据m_pOwner m_strName m_bEnabled

#ifndef __CC_FRAMEWORK_COMPONENT_H__

#define __CC_FRAMEWORK_COMPONENT_H__


#include "cocoa/CCObject.h"

#include <string>


NS_CC_BEGIN


class CC_DLL CCComponent : public CCObject  // Component 组件   成分

{

protected:

    CCComponent(void);

public:

    virtual ~CCComponent(void);

    virtual bool init();

    virtual void onEnter();

    virtual void onExit();

    virtual void update(float delta);

    virtual void serialize(void* r);//使连续

    virtual bool isEnabled() const;

    virtual void setEnabled(bool b);

    static CCComponent* create(void);

    

    const char* getName() const;

  //设置 得到拥有者

    void setOwner(CCNode *pOwner);

    CCNode* getOwner() const;

    

protected:

    CCNode *m_pOwner;

    std::string m_strName;

    bool m_bEnabled;

};


NS_CC_END


#endif  // __FUNDATION__CCCOMPONENT_H__


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

#include "support/component/CCComponent.h"


NS_CC_BEGIN


CCComponent::CCComponent(void)

: m_pOwner(NULL)

, m_bEnabled(true)

{

}


CCComponent::~CCComponent(void)

{

}


bool CCComponent::init()

{

    return true;

}


void CCComponent::onEnter()

{

}


void CCComponent::onExit()

{

}


void CCComponent::update(float delta)

{

}


void CCComponent::serialize(void *ar)

{

}


CCComponent* CCComponent::create(void)

{

    CCComponent * pRet = new CCComponent();

    if (pRet != NULL && pRet->init())

    {

        pRet->autorelease();

    }

    else

    {

        CC_SAFE_DELETE(pRet);

    }

return pRet;

}


const char* CCComponent::getName() const

{

    return m_strName.c_str();

}


CCNode* CCComponent::getOwner() const

{

    return m_pOwner;

}


void CCComponent::setOwner(CCNode *pOwner)

{

    m_pOwner = pOwner;

}


bool CCComponent::isEnabled() const

{

    return m_bEnabled;

}


void CCComponent::setEnabled(bool b)

{

    m_bEnabled = b;

}







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值