mirror of https://github.com/axmolengine/axmol.git
fixed #1837: Refactoring schedule binding codes.
* 1) We need bind cc.Node.scheduleUpdate and cc.Scheduler.scheduleUpdate manually since `schedules` need to be associated with _schedFunc_target_ht and _schedObj_target_ht * 2) Bind cc.Scheduler.unscheduleCallbackForTarget.
This commit is contained in:
parent
62d7dd5002
commit
f57a751a48
|
@ -472,8 +472,8 @@ void CCScheduler::scheduleUpdateForTarget(CCObject *pTarget, int nPriority, bool
|
||||||
if (nPriority == 0)
|
if (nPriority == 0)
|
||||||
{
|
{
|
||||||
appendIn(&m_pUpdates0List, pTarget, bPaused);
|
appendIn(&m_pUpdates0List, pTarget, bPaused);
|
||||||
} else
|
}
|
||||||
if (nPriority < 0)
|
else if (nPriority < 0)
|
||||||
{
|
{
|
||||||
priorityIn(&m_pUpdatesNegList, pTarget, nPriority, bPaused);
|
priorityIn(&m_pUpdatesNegList, pTarget, nPriority, bPaused);
|
||||||
}
|
}
|
||||||
|
@ -785,18 +785,11 @@ void CCScheduler::update(float dt)
|
||||||
// Iterate over all the Updates' selectors
|
// Iterate over all the Updates' selectors
|
||||||
tListEntry *pEntry, *pTmp;
|
tListEntry *pEntry, *pTmp;
|
||||||
|
|
||||||
CCScriptEngineProtocol* pEngine = CCScriptEngineManager::sharedManager()->getScriptEngine();
|
|
||||||
|
|
||||||
// updates with priority < 0
|
// updates with priority < 0
|
||||||
DL_FOREACH_SAFE(m_pUpdatesNegList, pEntry, pTmp)
|
DL_FOREACH_SAFE(m_pUpdatesNegList, pEntry, pTmp)
|
||||||
{
|
{
|
||||||
if ((! pEntry->paused) && (! pEntry->markedForDeletion))
|
if ((! pEntry->paused) && (! pEntry->markedForDeletion))
|
||||||
{
|
{
|
||||||
if (pEngine != NULL && kScriptTypeJavascript == pEngine->getScriptType())
|
|
||||||
{
|
|
||||||
pEngine->executeSchedule(0, dt, (CCNode *)pEntry->target);
|
|
||||||
}
|
|
||||||
|
|
||||||
pEntry->target->update(dt);
|
pEntry->target->update(dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -806,11 +799,6 @@ void CCScheduler::update(float dt)
|
||||||
{
|
{
|
||||||
if ((! pEntry->paused) && (! pEntry->markedForDeletion))
|
if ((! pEntry->paused) && (! pEntry->markedForDeletion))
|
||||||
{
|
{
|
||||||
if (pEngine != NULL && kScriptTypeJavascript == pEngine->getScriptType())
|
|
||||||
{
|
|
||||||
pEngine->executeSchedule(0, dt, (CCNode *)pEntry->target);
|
|
||||||
}
|
|
||||||
|
|
||||||
pEntry->target->update(dt);
|
pEntry->target->update(dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -820,11 +808,6 @@ void CCScheduler::update(float dt)
|
||||||
{
|
{
|
||||||
if ((! pEntry->paused) && (! pEntry->markedForDeletion))
|
if ((! pEntry->paused) && (! pEntry->markedForDeletion))
|
||||||
{
|
{
|
||||||
if (pEngine != NULL && kScriptTypeJavascript == pEngine->getScriptType())
|
|
||||||
{
|
|
||||||
pEngine->executeSchedule(0, dt, (CCNode *)pEntry->target);
|
|
||||||
}
|
|
||||||
|
|
||||||
pEntry->target->update(dt);
|
pEntry->target->update(dt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1105,7 +1105,7 @@ void CCNode::update(float fDelta)
|
||||||
{
|
{
|
||||||
if (m_nUpdateScriptHandler)
|
if (m_nUpdateScriptHandler)
|
||||||
{
|
{
|
||||||
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(m_nUpdateScriptHandler, fDelta);
|
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(m_nUpdateScriptHandler, fDelta, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
||||||
|
fa5b9ac318ba66fa30f0aa5955bfed23f79e4ee1
|
|
@ -142,13 +142,18 @@ public:
|
||||||
class JSScheduleWrapper: public JSCallbackWrapper {
|
class JSScheduleWrapper: public JSCallbackWrapper {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
JSScheduleWrapper() : _pTarget(NULL), _pPureJSTarget(NULL) {}
|
JSScheduleWrapper() : _pTarget(NULL), _pPureJSTarget(NULL), _priority(0), _isUpdateSchedule(false) {}
|
||||||
virtual ~JSScheduleWrapper();
|
virtual ~JSScheduleWrapper();
|
||||||
|
|
||||||
static void setTargetForSchedule(jsval sched, JSScheduleWrapper *target);
|
static void setTargetForSchedule(jsval sched, JSScheduleWrapper *target);
|
||||||
static CCArray * getTargetForSchedule(jsval sched);
|
static CCArray * getTargetForSchedule(jsval sched);
|
||||||
static void setTargetForJSObject(JSObject* jsTargetObj, JSScheduleWrapper *target);
|
static void setTargetForJSObject(JSObject* jsTargetObj, JSScheduleWrapper *target);
|
||||||
static CCArray * getTargetForJSObject(JSObject* jsTargetObj);
|
static CCArray * getTargetForJSObject(JSObject* jsTargetObj);
|
||||||
|
|
||||||
|
// Remove all targets.
|
||||||
|
static void removeAllTargets();
|
||||||
|
// Remove all targets for priority.
|
||||||
|
static void removeAllTargetsForMinPriority(int minPriority);
|
||||||
// Remove all targets by js object from hash table(_schedFunc_target_ht and _schedObj_target_ht).
|
// Remove all targets by js object from hash table(_schedFunc_target_ht and _schedObj_target_ht).
|
||||||
static void removeAllTargetsForJSObject(JSObject* jsTargetObj);
|
static void removeAllTargetsForJSObject(JSObject* jsTargetObj);
|
||||||
// Remove the target by js object and the wrapper for native schedule.
|
// Remove the target by js object and the wrapper for native schedule.
|
||||||
|
@ -158,14 +163,25 @@ public:
|
||||||
void pause();
|
void pause();
|
||||||
|
|
||||||
void scheduleFunc(float dt) const;
|
void scheduleFunc(float dt) const;
|
||||||
|
virtual void update(float dt);
|
||||||
|
|
||||||
CCObject* getTarget();
|
CCObject* getTarget();
|
||||||
void setTarget(CCObject* pTarget);
|
void setTarget(CCObject* pTarget);
|
||||||
|
|
||||||
void setPureJSTarget(JSObject* jstarget);
|
void setPureJSTarget(JSObject* jstarget);
|
||||||
JSObject* getPureJSTarget();
|
JSObject* getPureJSTarget();
|
||||||
|
|
||||||
|
void setPriority(int priority);
|
||||||
|
int getPriority();
|
||||||
|
|
||||||
|
void setUpdateSchedule(bool isUpdateSchedule);
|
||||||
|
bool isUpdateSchedule();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CCObject* _pTarget;
|
CCObject* _pTarget;
|
||||||
JSObject* _pPureJSTarget;
|
JSObject* _pPureJSTarget;
|
||||||
|
int _priority;
|
||||||
|
bool _isUpdateSchedule;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,7 @@ int CCLuaEngine::executeCallFuncActionEvent(CCCallFunc* pAction, CCObject* pTarg
|
||||||
|
|
||||||
int CCLuaEngine::executeSchedule(int nHandler, float dt, CCNode* pNode/* = NULL*/)
|
int CCLuaEngine::executeSchedule(int nHandler, float dt, CCNode* pNode/* = NULL*/)
|
||||||
{
|
{
|
||||||
|
if (!nHandler) return 0;
|
||||||
m_stack->pushFloat(dt);
|
m_stack->pushFloat(dt);
|
||||||
return m_stack->executeFunctionByHandler(nHandler, 1);
|
return m_stack->executeFunctionByHandler(nHandler, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ classes = CCSprite.* CCScene CCNode.* CCDirector CCLayer.* CCMenu.* CCTouch CC.*
|
||||||
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
|
||||||
# functions from all classes.
|
# functions from all classes.
|
||||||
|
|
||||||
skip = CCNode::[.*Transform convertToWindowSpace ^setPosition$ getGrid setGLServerState description getShaderProgram getUserObject .*UserData getGLServerState unscheduleAllSelectors],
|
skip = CCNode::[.*Transform convertToWindowSpace ^setPosition$ getGrid setGLServerState description getShaderProgram getUserObject .*UserData getGLServerState .*schedule],
|
||||||
CCSprite::[getQuad displayFrame getBlendFunc ^setPosition$ setBlendFunc setSpriteBatchNode getSpriteBatchNode],
|
CCSprite::[getQuad displayFrame getBlendFunc ^setPosition$ setBlendFunc setSpriteBatchNode getSpriteBatchNode],
|
||||||
CCSpriteBatchNode::[getBlendFunc setBlendFunc],
|
CCSpriteBatchNode::[getBlendFunc setBlendFunc],
|
||||||
CCMotionStreak::[getBlendFunc setBlendFunc],
|
CCMotionStreak::[getBlendFunc setBlendFunc],
|
||||||
|
@ -91,7 +91,7 @@ skip = CCNode::[.*Transform convertToWindowSpace ^setPosition$ getGrid setGLServ
|
||||||
CCCatmullRom.*::[create actionWithDuration],
|
CCCatmullRom.*::[create actionWithDuration],
|
||||||
CCBezier.*::[create actionWithDuration],
|
CCBezier.*::[create actionWithDuration],
|
||||||
CCCardinalSpline.*::[create actionWithDuration setPoints],
|
CCCardinalSpline.*::[create actionWithDuration setPoints],
|
||||||
CCScheduler::[pause resume unscheduleAllSelectorsForTarget],
|
CCScheduler::[pause resume unschedule schedule update isTargetPaused],
|
||||||
CCTextureCache::[addPVRTCImage],
|
CCTextureCache::[addPVRTCImage],
|
||||||
CCTimer::[getSelector],
|
CCTimer::[getSelector],
|
||||||
*::[copyWith.* onEnter.* onExit.* ^description$ getObjectType],
|
*::[copyWith.* onEnter.* onExit.* ^description$ getObjectType],
|
||||||
|
@ -113,7 +113,6 @@ rename_functions = CCDirector::[sharedDirector=getInstance],
|
||||||
CCTileMapAtlas::[tileAt=getTileAt],
|
CCTileMapAtlas::[tileAt=getTileAt],
|
||||||
CCSprite::[isFlipX=isFlippedX isFlipY=isFlippedY],
|
CCSprite::[isFlipX=isFlippedX isFlipY=isFlippedY],
|
||||||
CCTouch::[getID=getId],
|
CCTouch::[getID=getId],
|
||||||
CCScheduler::[unscheduleAllSelectorsForTarget=unscheduleAllCallbacksForTarget unscheduleAll=unscheduleAllCallbacks],
|
|
||||||
SimpleAudioEngine::[sharedEngine=getInstance preloadBackgroundMusic=preloadMusic setBackgroundMusicVolume=setMusicVolume getBackgroundMusicVolume=getMusicVolume playBackgroundMusic=playMusic stopBackgroundMusic=stopMusic pauseBackgroundMusic=pauseMusic resumeBackgroundMusic=resumeMusic rewindBackgroundMusic=rewindMusic isBackgroundMusicPlaying=isMusicPlaying willPlayBackgroundMusic=willPlayMusic],
|
SimpleAudioEngine::[sharedEngine=getInstance preloadBackgroundMusic=preloadMusic setBackgroundMusicVolume=setMusicVolume getBackgroundMusicVolume=getMusicVolume playBackgroundMusic=playMusic stopBackgroundMusic=stopMusic pauseBackgroundMusic=pauseMusic resumeBackgroundMusic=resumeMusic rewindBackgroundMusic=rewindMusic isBackgroundMusicPlaying=isMusicPlaying willPlayBackgroundMusic=willPlayMusic],
|
||||||
CCCamera.*::[setUpXYZ=setUp getUpXYZ=getUp setEyeXYZ=setEye getEyeXYZ=getEye setCenterXYZ=setCenter getCenterXYZ=getCenter],
|
CCCamera.*::[setUpXYZ=setUp getUpXYZ=getUp setEyeXYZ=setEye getEyeXYZ=getEye setCenterXYZ=setCenter getCenterXYZ=getCenter],
|
||||||
CCTMXTiledMap::[layerNamed=getLayer objectGroupNamed=getObjectGroup propertyNamed=getProperty],
|
CCTMXTiledMap::[layerNamed=getLayer objectGroupNamed=getObjectGroup propertyNamed=getProperty],
|
||||||
|
@ -134,7 +133,7 @@ base_classes_to_skip = CCObject
|
||||||
|
|
||||||
# classes that create no constructor
|
# classes that create no constructor
|
||||||
# CCSet is special and we will use a hand-written constructor
|
# CCSet is special and we will use a hand-written constructor
|
||||||
abstract_classes = CCDirector CCSpriteFrameCache CCTransitionEaseScene CCSet SimpleAudioEngine CCFileUtils CCScheduler
|
abstract_classes = CCDirector CCSpriteFrameCache CCTransitionEaseScene CCSet SimpleAudioEngine CCFileUtils
|
||||||
|
|
||||||
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
|
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
|
||||||
script_control_cpp = no
|
script_control_cpp = no
|
||||||
|
|
Loading…
Reference in New Issue