加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

cocos2dx3.0 Ref

发布时间:2020-12-14 19:42:53 所属栏目:百科 来源:网络整理
导读:转自:http://blog.csdn.net/w18767104183/article/details/25876481 cocos2dx中所有对象都继承于Ref,或者继承于 Ref和Clonable Ref中就是维护了一个计数器,用于判断该继承于Ref的对象是否应该delete [cpp] view plain copy class CC_DLLRef { public : //

转自:http://blog.csdn.net/w18767104183/article/details/25876481


cocos2dx中所有对象都继承于Ref,或者继承于 Ref和Clonable
Ref中就是维护了一个计数器,用于判断该继承于Ref的对象是否应该delete

[cpp] view plain copy
  1. classCC_DLLRef
  2. {
  3. public:
  4. //计数加1
  5. voidretain();
  6. //计数减1,如果为0,删除对象
  7. voidrelease();
  8. //添加到对象池中,别忘了PoolManager(对象池管理器)管理AutoreleasePool(对象池),AutoreleasePool管理Ref
  9. Ref*autorelease();
  10. //得到当前的计数
  11. unsignedintgetReferenceCount()const;
  12. protected:
  13. //创建时计数设为1
  14. Ref();
  15. public:
  16. virtual~Ref();
  17. protected:
  18. ///countofreferences
  19. //计数变量
  20. int_referenceCount;
  21. //友元类
  22. friendclassAutoreleasePool;
  23. #ifCC_ENABLE_SCRIPT_BINDING
  24. ///objectid,ScriptSupportneedpublic_ID
  25. int_ID;
  26. ///Luareferenceid
  27. int_luaID;
  28. #endif

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读