2012-06-14 05:19:13 +08:00
|
|
|
#include "HelloCocosBuilderLayer.h"
|
|
|
|
|
2012-06-15 05:23:53 +08:00
|
|
|
#include "../TestHeader/TestHeaderLayerLoader.h"
|
2012-06-15 09:16:54 +08:00
|
|
|
#include "../LabelTest/LabelTestLayerLoader.h"
|
2012-06-15 05:23:53 +08:00
|
|
|
#include "../ButtonTest/ButtonTestLayerLoader.h"
|
2012-06-15 09:16:54 +08:00
|
|
|
#include "../SpriteTest/SpriteTestLayerLoader.h"
|
|
|
|
#include "../MenuTest/MenuTestLayerLoader.h"
|
2012-06-16 05:48:36 +08:00
|
|
|
#include "../ParticleSystemTest/ParticleSystemTestLayerLoader.h"
|
2012-06-19 04:59:45 +08:00
|
|
|
#include "../ScrollViewTest/ScrollViewTestLayerLoader.h"
|
2012-06-14 05:19:13 +08:00
|
|
|
|
|
|
|
USING_NS_CC;
|
|
|
|
USING_NS_CC_EXT;
|
|
|
|
|
2012-06-19 16:31:26 +08:00
|
|
|
HelloCocosBuilderLayer::HelloCocosBuilderLayer()
|
|
|
|
: mBurstSprite(NULL)
|
|
|
|
, mTestTitleLabelTTF(NULL)
|
|
|
|
{}
|
|
|
|
|
|
|
|
HelloCocosBuilderLayer::~HelloCocosBuilderLayer()
|
|
|
|
{
|
|
|
|
CC_SAFE_RELEASE(mBurstSprite);
|
|
|
|
CC_SAFE_RELEASE(mTestTitleLabelTTF);
|
|
|
|
}
|
|
|
|
|
2012-06-14 05:19:13 +08:00
|
|
|
void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * pCCNodeName, CCNodeLoader * pCCNodeLoader) {
|
|
|
|
/* Create an autorelease CCNodeLoaderLibrary. */
|
|
|
|
CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
|
|
|
|
|
2012-09-17 14:27:17 +08:00
|
|
|
ccNodeLoaderLibrary->registerCCNodeLoader("TestHeader", TestHeaderLayerLoader::loader());
|
2012-06-14 05:19:13 +08:00
|
|
|
if(pCCNodeName != NULL && pCCNodeLoader != NULL) {
|
|
|
|
ccNodeLoaderLibrary->registerCCNodeLoader(pCCNodeName, pCCNodeLoader);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create an autorelease CCBReader. */
|
|
|
|
cocos2d::extension::CCBReader * ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
|
|
|
|
ccbReader->autorelease();
|
|
|
|
|
|
|
|
/* Read a ccbi file. */
|
|
|
|
// Load the scene from the ccbi-file, setting this class as
|
|
|
|
// the owner will cause lblTestTitle to be set by the CCBReader.
|
|
|
|
// lblTestTitle is in the TestHeader.ccbi, which is referenced
|
|
|
|
// from each of the test scenes.
|
2012-09-17 14:27:17 +08:00
|
|
|
CCNode * node = ccbReader->readNodeGraphFromFile(pCCBFileName, this);
|
2012-06-14 05:19:13 +08:00
|
|
|
|
|
|
|
this->mTestTitleLabelTTF->setString(pCCBFileName);
|
|
|
|
|
2012-06-20 12:08:34 +08:00
|
|
|
CCScene * scene = CCScene::create();
|
2012-06-14 05:19:13 +08:00
|
|
|
if(node != NULL) {
|
|
|
|
scene->addChild(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Push the new scene with a fancy transition. */
|
|
|
|
ccColor3B transitionColor;
|
|
|
|
transitionColor.r = 0;
|
|
|
|
transitionColor.g = 0;
|
|
|
|
transitionColor.b = 0;
|
|
|
|
|
2012-06-20 11:48:31 +08:00
|
|
|
CCDirector::sharedDirector()->pushScene(CCTransitionFade::create(0.5f, scene, transitionColor));
|
2012-06-14 05:19:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-07-19 17:22:36 +08:00
|
|
|
void HelloCocosBuilderLayer::onNodeLoaded(cocos2d::CCNode * pNode, cocos2d::extension::CCNodeLoader * pNodeLoader) {
|
2012-09-17 14:27:17 +08:00
|
|
|
CCRotateBy * ccRotateBy = CCRotateBy::create(20.0f, 360);
|
2012-06-20 11:48:31 +08:00
|
|
|
CCRepeatForever * ccRepeatForever = CCRepeatForever::create(ccRotateBy);
|
2012-06-14 05:19:13 +08:00
|
|
|
this->mBurstSprite->runAction(ccRepeatForever);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-15 09:16:54 +08:00
|
|
|
SEL_MenuHandler HelloCocosBuilderLayer::onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) {
|
2012-06-14 05:19:13 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) {
|
2012-06-15 09:16:54 +08:00
|
|
|
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onMenuTestClicked", HelloCocosBuilderLayer::onMenuTestClicked);
|
|
|
|
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onSpriteTestClicked", HelloCocosBuilderLayer::onSpriteTestClicked);
|
|
|
|
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onButtonTestClicked", HelloCocosBuilderLayer::onButtonTestClicked);
|
2012-09-17 14:27:17 +08:00
|
|
|
//CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onLabelTestClicked", HelloCocosBuilderLayer::onLabelTestClicked);
|
2012-06-15 09:16:54 +08:00
|
|
|
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onParticleSystemTestClicked", HelloCocosBuilderLayer::onParticleSystemTestClicked);
|
|
|
|
CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onScrollViewTestClicked", HelloCocosBuilderLayer::onScrollViewTestClicked);
|
|
|
|
|
2012-06-14 05:19:13 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-06-14 15:01:01 +08:00
|
|
|
bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode) {
|
2012-06-15 09:16:54 +08:00
|
|
|
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mBurstSprite", CCSprite *, this->mBurstSprite);
|
2012-06-16 05:48:36 +08:00
|
|
|
CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mTestTitleLabelTTF", CCLabelTTF *, this->mTestTitleLabelTTF);
|
2012-06-15 09:16:54 +08:00
|
|
|
|
2012-06-14 05:19:13 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void HelloCocosBuilderLayer::onMenuTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) {
|
2012-09-17 14:27:17 +08:00
|
|
|
this->openTest("TestMenus.ccbi", "TestMenus", MenuTestLayerLoader::loader());
|
2012-06-14 05:19:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void HelloCocosBuilderLayer::onSpriteTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) {
|
2012-09-17 14:27:17 +08:00
|
|
|
this->openTest("TestSprites.ccbi", "TestSprites", SpriteTestLayerLoader::loader());
|
2012-06-14 05:19:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void HelloCocosBuilderLayer::onButtonTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) {
|
2012-09-17 14:27:17 +08:00
|
|
|
this->openTest("TestButtons.ccbi", "TestButtons", ButtonTestLayerLoader::loader());
|
2012-06-14 05:19:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void HelloCocosBuilderLayer::onLabelTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) {
|
2012-09-17 14:27:17 +08:00
|
|
|
this->openTest("TestLabels.ccbi", "TestLabels", LabelTestLayerLoader::loader());
|
2012-06-14 05:19:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void HelloCocosBuilderLayer::onParticleSystemTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) {
|
2012-09-17 14:27:17 +08:00
|
|
|
this->openTest("TestParticleSystems.ccbi", "TestParticleSystems", ParticleSystemTestLayerLoader::loader());
|
2012-06-14 05:19:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void HelloCocosBuilderLayer::onScrollViewTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) {
|
2012-09-17 14:27:17 +08:00
|
|
|
this->openTest("TestScrollViews.ccbi", "TestScrollViews", ScrollViewTestLayerLoader::loader());
|
2012-06-14 05:19:13 +08:00
|
|
|
}
|