mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-22 02:45:49 -04:00
add CCScene::get + CCScheduler::get + CCNode::hasAncestor
This commit is contained in:
parent
7305445f05
commit
38575ac825
5 changed files with 49 additions and 8 deletions
loader
include/Geode/cocos
src/cocos2d-ext
6
loader/include/Geode/cocos/CCScheduler.h
vendored
6
loader/include/Geode/cocos/CCScheduler.h
vendored
|
@ -285,6 +285,12 @@ public:
|
|||
*/
|
||||
void resumeTargets(CCSet* targetsToResume);
|
||||
|
||||
/**
|
||||
* Get the shared scheduler from CCDirector
|
||||
* @note Geode addition
|
||||
*/
|
||||
static GEODE_DLL CCScheduler* get();
|
||||
|
||||
private:
|
||||
void removeHashElement(struct _hashSelectorEntry *pElement);
|
||||
void removeUpdateFromHash(struct _listEntry *entry);
|
||||
|
|
12
loader/include/Geode/cocos/base_nodes/CCNode.h
vendored
12
loader/include/Geode/cocos/base_nodes/CCNode.h
vendored
|
@ -894,6 +894,7 @@ public:
|
|||
* @param before The child the node is added before of. If this is null or
|
||||
* not a child of this node, the new child will be placed at the start of the
|
||||
* child list
|
||||
* @note Geode addition
|
||||
*/
|
||||
GEODE_DLL void insertBefore(CCNode* child, CCNode* before);
|
||||
|
||||
|
@ -904,9 +905,20 @@ public:
|
|||
* @param after The child the node is added after of. If this is null or
|
||||
* not a child of this node, the new child will be placed at the end of the
|
||||
* child list
|
||||
* @note Geode addition
|
||||
*/
|
||||
GEODE_DLL void insertAfter(CCNode* child, CCNode* after);
|
||||
|
||||
/**
|
||||
* Check if this node's parent or its parents' parent is the given node
|
||||
* @param ancestor The node whose child or subchild this node should be. If
|
||||
* nullptr, returns true if the node is in the current scene, otherwise
|
||||
* false.
|
||||
* @returns True if ancestor is an ancestor of this node
|
||||
* @note Geode addition
|
||||
*/
|
||||
GEODE_DLL bool hasAncestor(CCNode* ancestor);
|
||||
|
||||
/**
|
||||
* Set an attribute on a node. Attributes are a system added by Geode,
|
||||
* where a node may have any sort of extra data associated with it. Used
|
||||
|
|
|
@ -71,17 +71,19 @@ public:
|
|||
virtual ~CCScene();
|
||||
bool init();
|
||||
|
||||
static CCScene *create(void);
|
||||
static CCScene* create(void);
|
||||
/**
|
||||
* Get the running scene
|
||||
* @note Geode addition
|
||||
*/
|
||||
static GEODE_DLL CCScene* get();
|
||||
|
||||
RT_ADD(
|
||||
CCScene(const CCScene&);
|
||||
|
||||
CCScene& operator=(const CCScene&);
|
||||
CCScene(const CCScene&);
|
||||
CCScene& operator=(const CCScene&);
|
||||
|
||||
int getHighestChildZ(void);
|
||||
int getHighestChildZ(void);
|
||||
|
||||
CCSceneDelegate* m_pDelegate;
|
||||
)
|
||||
CCSceneDelegate* m_pDelegate;
|
||||
};
|
||||
|
||||
// end of scene group
|
||||
|
|
|
@ -37,4 +37,12 @@ CCTextureCache* CCTextureCache::get() {
|
|||
return CCTextureCache::sharedTextureCache();
|
||||
}
|
||||
|
||||
CCScene* CCScene::get() {
|
||||
return CCDirector::get()->getRunningScene();
|
||||
}
|
||||
|
||||
CCScheduler* CCScheduler::get() {
|
||||
return CCDirector::get()->getScheduler();
|
||||
}
|
||||
|
||||
#pragma warning(pop)
|
||||
|
|
|
@ -37,6 +37,19 @@ void CCNode::insertAfter(CCNode* child, CCNode* after) {
|
|||
}
|
||||
}
|
||||
|
||||
bool CCNode::hasAncestor(CCNode* ancestor) {
|
||||
if (!ancestor) {
|
||||
ancestor = CCScene::get();
|
||||
}
|
||||
if (m_pParent == ancestor) {
|
||||
return true;
|
||||
}
|
||||
if (m_pParent) {
|
||||
return m_pParent->hasAncestor(ancestor);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
CCArray* Layout::getNodesToPosition(CCNode* on) {
|
||||
if (!on->getChildren()) {
|
||||
return CCArray::create();
|
||||
|
|
Loading…
Reference in a new issue