fixed #958: delete SelectorProtocol and implement it in CCObject

This commit is contained in:
minggo 2012-01-30 17:47:47 +08:00
parent c6ec949950
commit 6c2277757a
19 changed files with 52 additions and 104 deletions

View File

@ -1 +1 @@
d1f0ba1c97add6d33ba2628f3a35ad1ed676c4f5
0a874bd51db1bbbd82d2c0ed77650a0ac0f323f6

View File

@ -1 +1 @@
0bf2e5e584ed953f8de4c1594175403a1d14abd0
27ae070112e44d08eaf37af409452a684dcb4185

View File

@ -1 +1 @@
9cfad9940e7c5ab477855e3c4364e2df0274e878
aab1f3b11ba297c9558f3f4aefa80696fed4dca6

View File

@ -1 +1 @@
84d1a5cd21bd26c8e2f08241d504b59fe40defc9
60686646874bc76241984a6df8beeaa3673f934e

View File

@ -1 +1 @@
1a854b530b8894d2453fe8777d2d83b8bc68ab91
b8d0b27908d823a2687767793e04c64fe1541def

View File

@ -1 +1 @@
866c5fd880bbb121951818d47d13a4ee914279ad
4df124f68856ca5915635b8392bb8aa85c79259f

View File

@ -1 +1 @@
6b542917dfd2180ff6c55bca6cd7b30c64c4a300
23cd0723f3707e7fc8c77d718bf3fc0b81b105f6

View File

@ -1 +1 @@
da69ff183d2f96f95b8b1f8aec196130ba76a193
6f3595799e6b2dd55a7666a9a191c04093559b7f

View File

@ -1,11 +1,10 @@
#include "CCAction.h"
#include "selector_protocol.h"
namespace cocos2d {
class CCActionInstant : public CCFiniteTimeAction //<NSCopying>
class CCActionInstant : public CCFiniteTimeAction
{
public:
CCActionInstant();
@ -91,25 +90,25 @@ namespace cocos2d {
class CCCallFunc : public CCActionInstant //<NSCopying>
{
CCCallFunc();
static CCCallFunc * actionWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFunc selector);
static CCCallFunc * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFunc selector);
static CCCallFunc* actionWithScriptFuncName(const char* pszFuncName);
bool initWithTarget(SelectorProtocol* pSelectorTarget);
bool initWithTarget(CCObject* pSelectorTarget);
bool initWithScriptFuncName(const char* pszFuncName);
void execute();
void startWithTarget(CCNode *pTarget);
CCObject * copyWithZone(cocos2d::CCZone *pZone);
SelectorProtocol* getTargetCallback();
void setTargetCallback(SelectorProtocol* pSel);
CCObject* getTargetCallback();
void setTargetCallback(CCObject* pSel);
};
class CCCallFuncN : public CCCallFunc
{
CCCallFuncN();
static CCCallFuncN * actionWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncN selector);
static CCCallFuncN * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncN selector);
static CCCallFuncN* actionWithScriptFuncName(const char* pszFuncName);
bool initWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncN selector);
bool initWithTarget(CCObject* pSelectorTarget, SEL_CallFuncN selector);
CCObject* copyWithZone(CCZone *pZone);
void execute();
};
@ -120,10 +119,10 @@ namespace cocos2d {
{
/** creates the action with the callback and the data to pass as an argument */
static CCCallFuncND * actionWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncND selector, void* d);
static CCCallFuncND * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d);
static CCCallFuncND* actionWithScriptFuncName(const char* pszFuncName, void *d);
/** initializes the action with the callback and the data to pass as an argument */
virtual bool initWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncND selector, void* d);
virtual bool initWithTarget(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d);
// super methods
virtual CCObject* copyWithZone(CCZone *pZone);
virtual void execute();
@ -137,10 +136,10 @@ namespace cocos2d {
CCCallFuncO();
static CCCallFuncO * actionWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject);
static CCCallFuncO * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject);
static CCCallFuncO* actionWithScriptFuncName(const char* pszFuncName);
bool initWithTarget(SelectorProtocol* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject);
bool initWithTarget(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject);
CCObject* copyWithZone(CCZone *pZone);
void execute();

View File

@ -2,13 +2,12 @@
#include "CCAction.h"
#include "CCMutableArray.h"
#include "CCObject.h"
#include "selector_protocol.h"
namespace cocos2d {
struct _hashElement;
class CCActionManager : public CCObject, public SelectorProtocol
class CCActionManager : public CCObject
{
public:
CCActionManager(void);

View File

@ -30,11 +30,6 @@ namespace cocos2d{
int bottom;
} ccBMFontPadding;
enum {
// how many characters are supported
kCCBMFontMaxChars = 2048, //256,
};
class CCBMFontConfiguration : public CCObject
{

View File

@ -1,6 +1,5 @@
#include "CCNode.h"
#include "CCProtocols.h"
#include "selector_protocol.h"
namespace cocos2d{
@ -15,8 +14,8 @@ namespace cocos2d{
public:
CCMenuItem();
static CCMenuItem * itemWithTarget(SelectorProtocol *rec, SEL_MenuHandler selector);
bool initWithTarget(SelectorProtocol *rec, SEL_MenuHandler selector);
static CCMenuItem * itemWithTarget(CCObject *rec, SEL_MenuHandler selector);
bool initWithTarget(CCObject *rec, SEL_MenuHandler selector);
CCRect rect();
void activate();
@ -33,10 +32,10 @@ namespace cocos2d{
public:
CCMenuItemLabel();
static CCMenuItemLabel * itemWithLabel(CCNode*label, SelectorProtocol* target, SEL_MenuHandler selector);
static CCMenuItemLabel * itemWithLabel(CCNode*label, CCObject* target, SEL_MenuHandler selector);
static CCMenuItemLabel* itemWithLabel(CCNode *label);
bool initWithLabel(CCNode* label, SelectorProtocol* target, SEL_MenuHandler selector);
bool initWithLabel(CCNode* label, CCObject* target, SEL_MenuHandler selector);
void setString(const char * label);
@ -60,9 +59,9 @@ namespace cocos2d{
CCMenuItemAtlasFont();
static CCMenuItemAtlasFont* itemFromString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap);
/** creates a menu item from a string and atlas. Use it with MenuItemToggle */
static CCMenuItemAtlasFont* itemFromString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol* target, SEL_MenuHandler selector);
static CCMenuItemAtlasFont* itemFromString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector);
/** initializes a menu item from a string and atlas with a target/selector */
bool initFromString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, SelectorProtocol* target, SEL_MenuHandler selector);
bool initFromString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector);
};
class CCMenuItemFont : public CCMenuItemLabel
@ -79,9 +78,9 @@ namespace cocos2d{
/** creates a menu item from a string without target/selector. To be used with CCMenuItemToggle */
static CCMenuItemFont * itemFromString(const char *value);
/** creates a menu item from a string with a target/selector */
static CCMenuItemFont * itemFromString(const char *value, SelectorProtocol* target, SEL_MenuHandler selector);
static CCMenuItemFont * itemFromString(const char *value, CCObject* target, SEL_MenuHandler selector);
/** initializes a menu item from a string with a target/selector */
bool initFromString(const char *value, SelectorProtocol* target, SEL_MenuHandler selector);
bool initFromString(const char *value, CCObject* target, SEL_MenuHandler selector);
};
@ -89,9 +88,9 @@ namespace cocos2d{
{
CCMenuItemSprite();
static CCMenuItemSprite * itemFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite);
static CCMenuItemSprite * itemFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, SelectorProtocol* target, SEL_MenuHandler selector);
static CCMenuItemSprite * itemFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, SelectorProtocol* target, SEL_MenuHandler selector);
bool initFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, SelectorProtocol* target, SEL_MenuHandler selector);
static CCMenuItemSprite * itemFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector);
static CCMenuItemSprite * itemFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector);
bool initFromNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector);
void setColor(ccColor3B color);
ccColor3B getColor();
void setOpacity(GLubyte opacity);
@ -108,9 +107,9 @@ namespace cocos2d{
CCMenuItemImage();
static CCMenuItemImage* itemFromNormalImage(const char *normalImage, const char *selectedImage);
static CCMenuItemImage* itemFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage);
static CCMenuItemImage* itemFromNormalImage(const char *normalImage, const char *selectedImage, SelectorProtocol* target, SEL_MenuHandler selector);
static CCMenuItemImage* itemFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, SelectorProtocol* target, SEL_MenuHandler selector);
bool initFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, SelectorProtocol* target, SEL_MenuHandler selector);
static CCMenuItemImage* itemFromNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector);
static CCMenuItemImage* itemFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector);
bool initFromNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector);
void setColor(ccColor3B color);
ccColor3B getColor();
void setOpacity(GLubyte opacity);

View File

@ -3,7 +3,7 @@ enum {
kCCNodeTagInvalid = -1,
};
class CCNode : public CCObject, public SelectorProtocol
class CCNode : public CCObject
{
CCNode();
int getZOrder();

View File

@ -1,3 +1,5 @@
#include "ccTypes.h"
namespace cocos2d {
class CCCopying
@ -19,6 +21,7 @@ class CCObject : public CCCopying
bool isSingleRefrence(void);
unsigned int retainCount(void);
bool isEqual(const CCObject* pObject);
void update(ccTime dt);
};
}//namespace cocos2d

View File

@ -84,7 +84,7 @@ class CCLabelProtocol
};
/** OpenGL projection protocol */
class CCProjectionProtocol : public CCObject
class CCProjectionProtocol
{
/** Called by CCDirector when the porjection is updated, and "custom" projection is used

View File

@ -10,15 +10,15 @@ class CCTimer : public CCObject
void setInterval(ccTime fInterval);
//bool initWithTarget(SelectorProtocol *pTarget, SEL_SCHEDULE pfnSelector);
//bool initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector);
//bool initWithTarget(SelectorProtocol *pTarget, SEL_SCHEDULE pfnSelector, ccTime fSeconds);
//bool initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, ccTime fSeconds);
void update(ccTime dt);
//static CCTimer* timerWithTarget(SelectorProtocol *pTarget, SEL_SCHEDULE pfnSelector);
//static CCTimer* timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector);
//static CCTimer* timerWithTarget(SelectorProtocol *pTarget, SEL_SCHEDULE pfnSelector, ccTime fSeconds);
//static CCTimer* timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, ccTime fSeconds);
bool initWithScriptFuncName(const char *pszFuncName, ccTime fSeconds);
bool initWithScriptFuncName(const char *pszFuncName, ccTime fSeconds);
@ -41,25 +41,25 @@ class CCScheduler : public CCObject
void tick(ccTime dt);
void scheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol *pTarget, ccTime fInterval, bool bPaused);
void scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, ccTime fInterval, bool bPaused);
void scheduleScriptFunc(const char *pszFuncName, ccTime fInterval, bool bPaused);
void unscheduleScriptFunc(const char *pszFuncName);
void scheduleUpdateForTarget(SelectorProtocol *pTarget, int nPriority, bool bPaused);
void scheduleUpdateForTarget(CCObject *pTarget, int nPriority, bool bPaused);
void unscheduleSelector(SEL_SCHEDULE pfnSelector, SelectorProtocol *pTarget);
void unscheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget);
void unscheduleUpdateForTarget(const SelectorProtocol *pTarget);
void unscheduleUpdateForTarget(const CCObject *pTarget);
void unscheduleAllSelectorsForTarget(SelectorProtocol *pTarget);
void unscheduleAllSelectorsForTarget(CCObject *pTarget);
void unscheduleAllSelectors(void);
void pauseTarget(SelectorProtocol *pTarget);
void pauseTarget(CCObject *pTarget);
void resumeTarget(SelectorProtocol *pTarget);
void resumeTarget(CCObject *pTarget);
bool isTargetPaused(SelectorProtocol *pTarget);
bool isTargetPaused(CCObject *pTarget);
static CCScheduler* sharedScheduler(void);

View File

@ -17,7 +17,7 @@ class CCTextureCache : public CCObject
CCTexture2D* addUIImage(CCImage *image, const char *key);
void addImageAsync(const char *path, CCObject *target, SEL_CallFuncO selector);
CCTexture2D* textureForKey(const char* key);

View File

@ -68,7 +68,6 @@ $pfile "CCAction.pkg"
$pfile "CCProtocols.pkg"
$pfile "selector_protocol.pkg"
$pfile "CCSet.pkg"
$pfile "CCMutableArray.pkg"

View File

@ -1,46 +0,0 @@
namespace cocos2d {
class CCNode;
class CCEvent;
class SelectorProtocol
{
public:
SelectorProtocol();
void update(ccTime dt);
void tick(ccTime dt);
void callfunc();
void callfunc(CCNode* pSender);
void callfunc(CCNode* pSender, void* pData);
void menuHandler(CCObject* pSender);
void eventHandler(CCEvent* pEvent);
};
/*
class CCNode;
typedef void (SelectorProtocol::*SEL_SCHEDULE)(ccTime);
typedef void (SelectorProtocol::*SEL_CallFunc)();
typedef void (SelectorProtocol::*SEL_CallFuncN)(CCNode*);
typedef void (SelectorProtocol::*SEL_CallFuncND)(CCNode*, void*);
typedef void (SelectorProtocol::*SEL_CallFuncO)(CCObject*);
typedef void (SelectorProtocol::*SEL_MenuHandler)(CCObject*);
typedef void (SelectorProtocol::*SEL_EventHandler)(CCEvent*);
// #define schedule_selector(_SELECTOR) (SEL_SCHEDULE)(*((SEL_SCHEDULE*)(&(&_SELECTOR))) )
// #define callfunc_selector(_SELECTOR) (SEL_CallFunc)(*((SEL_CallFunc*)(&(&_SELECTOR))) )
// #define callfuncN_selector(_SELECTOR) (SEL_CallFuncN)(*((SEL_CallFuncN*)(&(&_SELECTOR))) )
// #define callfuncND_selector(_SELECTOR) (SEL_CallFuncND)(*((SEL_CallFuncND*)(&(&_SELECTOR))) )
// #define menu_selector(_SELECTOR) (SEL_MenuHandler)(*((SEL_MenuHandler*)(&(&_SELECTOR)))
#define schedule_selector(_SELECTOR) (SEL_SCHEDULE)(&_SELECTOR)
#define callfunc_selector(_SELECTOR) (SEL_CallFunc)(&_SELECTOR)
#define callfuncN_selector(_SELECTOR) (SEL_CallFuncN)(&_SELECTOR)
#define callfuncND_selector(_SELECTOR) (SEL_CallFuncND)(&_SELECTOR)
#define callfuncO_selector(_SELECTOR) (SEL_CallFuncO)(&_SELECTOR)
#define menu_selector(_SELECTOR) (SEL_MenuHandler)(&_SELECTOR)
#define event_selector(_SELECTOR) (SEL_EventHandler)(&_SELECTOR)
*/
}//namespace cocos2d