创建筛选器,为了给类分类存放,方便管理维护。其实就是创建文件夹,但这是虚拟的文件夹,对代码文件的只是路径不会产生任何不良影响。
创建实体基类:
Entity.h
#ifndef __Entity_H__ #define __Entity_H__ #include "cocos2d.h" USING_NS_CC; class Entity :public Node{ public: Entity(); ~Entity(); Sprite* getSprite(); void bindSprite(Sprite* sprite); private: Sprite* m_sprite; }; #endif
Entity.cpp
#include "Player.h" #include "Entity.h" Entity::Entity(){ m_sprite=NULL; } Entity::~Entity(){ } Sprite* Entity::getSprite(){ return this->m_sprite; } void Entity::bindSprite(Sprite* sprite){ this->m_sprite=sprite; this->addChild(m_sprite); }