mirror of
https://github.com/geode-sdk/geode.git
synced 2025-03-23 03:15:58 -04:00
add geode::cocos::switchToScene utility
This commit is contained in:
parent
5a8bc843dc
commit
17014b6302
3 changed files with 20 additions and 0 deletions
loader
|
@ -1,5 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include "../DefaultInclude.hpp"
|
||||
#include <cocos2d.h>
|
||||
|
||||
namespace cocos2d {
|
||||
class CCArray;
|
||||
class CCNode;
|
||||
|
|
|
@ -123,6 +123,14 @@ namespace geode::cocos {
|
|||
*/
|
||||
GEODE_DLL cocos2d::CCRect calculateChildCoverage(cocos2d::CCNode* parent);
|
||||
|
||||
/**
|
||||
* Create a CCScene from a layer and switch to it with the default fade
|
||||
* transition
|
||||
* @param layer Layer to create a scene from
|
||||
* @returns Created scene (not the fade transition)
|
||||
*/
|
||||
GEODE_DLL cocos2d::CCScene* switchToScene(cocos2d::CCLayer* layer);
|
||||
|
||||
/**
|
||||
* Rescale node to fit inside given size
|
||||
* @param node Node to rescale
|
||||
|
|
|
@ -99,3 +99,12 @@ bool geode::cocos::fileExistsInSearchPaths(const char* filename) {
|
|||
auto utils = CCFileUtils::sharedFileUtils();
|
||||
return utils->isFileExist(utils->fullPathForFilename(filename, false));
|
||||
}
|
||||
|
||||
CCScene* geode::cocos::switchToScene(CCLayer* layer) {
|
||||
auto scene = CCScene::create();
|
||||
scene->addChild(layer);
|
||||
CCDirector::get()->replaceScene(CCTransitionFade::create(
|
||||
.5f, scene
|
||||
));
|
||||
return scene;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue