示例#1
0
bool Background::Init()
{
    do
    {
        CCNodeLoaderLibrary * ccNodeLoaderLibraryLeft = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
        CCBReader * ccbReaderLeft = new CCBReader(ccNodeLoaderLibraryLeft);
        CCNode * bgLeft = ccbReaderLeft->readNodeGraphFromFile("ccb/background.ccbi", this);
        CCBAnimationManager* animationManagerLeft = ccbReaderLeft->getAnimationManager();
        animationManagerLeft->runAnimationsForSequenceNamed("left");
        ccbReaderLeft->release();
        
        CCNodeLoaderLibrary * ccNodeLoaderLibraryRight = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
        CCBReader * ccbReaderRight = new CCBReader(ccNodeLoaderLibraryRight);
        CCNode * bgRight = ccbReaderRight->readNodeGraphFromFile("ccb/background.ccbi", this);
        CCBAnimationManager* animationManagerRight = ccbReaderRight->getAnimationManager();
        animationManagerRight->runAnimationsForSequenceNamed("right");
        ccbReaderRight->release();
        
        CCClippingNode * clippingNodeLeft = CCClippingNode::create();
        addChild(clippingNodeLeft);
        clippingNodeLeft->addChild(bgLeft,enZOrderBack,enTagBgLeft);
        CCDrawNode *shapeLeft = CCDrawNode::create();
        static CCPoint triangleLeft[3];
        triangleLeft[0] = ccp(0, 0);
        triangleLeft[1] = ccp(SCREEN_WIDTH,0);
        triangleLeft[2] = ccp(0,SCREEN_HEIGHT);
        static ccColor4F green = {0, 1, 0, 1};
        shapeLeft->drawPolygon(triangleLeft, 3, green, 0, green);
        clippingNodeLeft->setStencil(shapeLeft);
        clippingNodeLeft->setInverted(false);
        
        CCClippingNode * clippingNodeRight = CCClippingNode::create();
        addChild(clippingNodeRight);
        clippingNodeRight->addChild(bgRight,enZOrderBack,enTagBgRight);
        CCDrawNode *shapeRight = CCDrawNode::create();
        static CCPoint triangleRight[3];
        triangleRight[0] = ccp(SCREEN_WIDTH, SCREEN_HEIGHT);
        triangleRight[1] = ccp(SCREEN_WIDTH,0);
        triangleRight[2] = ccp(0,SCREEN_HEIGHT);
//        static ccColor4F green = {0, 1, 0, 1};
        shapeRight->drawPolygon(triangleRight, 3, green, 0, green);
        clippingNodeRight->setStencil(shapeRight);
        clippingNodeRight->setInverted(false);
        
        m_CraterArrayLeft = CCArray::create();
        m_CraterArrayLeft->retain();
        m_CraterArrayRight = CCArray::create();
        m_CraterArrayRight->retain();
        m_CraterArrayLeftDeleted = CCArray::create();
        m_CraterArrayLeftDeleted->retain();
        m_CraterArrayRightDeleted = CCArray::create();
        m_CraterArrayRightDeleted->retain();
        
        
        return true;
    } while (false);
    CCLog("Function Background::Init Error!");
    return false;
}
示例#2
0
void Background::OnDead(enUnitIndex target, CCPoint targetPos)
{
    enUnitType eType = GlobalData::sharedDirector()->getUnitTypeByIndex(target);
    unitDataMap unitData = GlobalData::sharedDirector()->getUnitDefaultData();
//    unitPosMap unitsPos = GlobalData::sharedDirector()->getUnitPos();
    
    if(eType==enUnitTypeTroopMine ||
       eType==enUnitTypeTroopEnemy)
    {
        CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
        CCBReader * ccbReader = new CCBReader(ccNodeLoaderLibrary);
        CCNode * ccbNode = ccbReader->readNodeGraphFromFile(unitData[eType].strCCBI.c_str(), this);
        CCBAnimationManager* animationManager = ccbReader->getAnimationManager();
        animationManager->runAnimationsForSequenceNamed("dead");
        ccbReader->release();
        ccbNode->setScaleX(0.5);//the bg sprite in ccb is scale.
        
        if(target<enUnitIndexEnemy1)
        {
            m_backgroundLeft->addChild(ccbNode);
            ccbNode->setPosition(m_backgroundLeft->convertToNodeSpace(targetPos));
            m_CraterArrayLeft->addObject(ccbNode);
        }
        else
        {
            m_backgroundRight->addChild(ccbNode);
            ccbNode->setPosition(m_backgroundRight->convertToNodeSpace(targetPos));
            m_CraterArrayRight->addObject(ccbNode);
        }
    }
    else if(eType==enUnitTypeCarMine ||
            eType==enUnitTypeCarEnemy)
    {
        CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
        CCBReader * ccbReader = new CCBReader(ccNodeLoaderLibrary);
        CCNode * ccbNode = ccbReader->readNodeGraphFromFile("ccb/boom.ccbi", this);
        CCBAnimationManager* animationManager = ccbReader->getAnimationManager();
        animationManager->runAnimationsForSequenceNamed("boom");
        ccbReader->release();
        ccbNode->setScaleX(0.5);//the bg sprite in ccb is scale.
        
        if(target<enUnitIndexEnemy1)
        {
            m_backgroundLeft->addChild(ccbNode);
            ccbNode->setPosition(m_backgroundLeft->convertToNodeSpace(targetPos));
            m_CraterArrayLeft->addObject(ccbNode);
        }
        else
        {
            m_backgroundRight->addChild(ccbNode);
            ccbNode->setPosition(m_backgroundRight->convertToNodeSpace(targetPos));
            m_CraterArrayRight->addObject(ccbNode);
        }
    }
}
示例#3
0
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance();
    auto eglView = EGLView::getInstance();

    director->setOpenGLView(eglView);
    
    // turn on display FPS
    director->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);
    
    // create a scene. it's an autorelease object
    auto scene = Scene::create();
#if 0
    NodeLoaderLibrary *pLoaderLibrary = NodeLoaderLibrary::newDefaultNodeLoaderLibrary();
    CCBReader *ccbReader = new CCBReader(pLoaderLibrary);
    pLoaderLibrary->registerNodeLoader("plane_figtht_main", XCMainMenuLoader::loader());
    Node *pMainMenu = ccbReader->readNodeGraphFromFile("ccb/ccbi/plane_fight_main.ccbi");
    dynamic_cast<XCMainMenu*>(pMainMenu)->setAnimationManager(ccbReader->getAnimationManager());
    dynamic_cast<XCMainMenu*>(pMainMenu)->initPlaneMain();
    ccbReader->release();
    scene->addChild(pMainMenu); 
#else
    
#endif
    
    // run
    director->runWithScene(scene);

    return true;
}
示例#4
0
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
    //CCDirector::sharedDirector()->end();

//#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    //exit(0);
//    CCNodeLoaderLibrary* ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
//    CCBReader* reader = new CCBReader(ccNodeLoaderLibrary);
//    CCScene* scene = reader->createSceneWithNodeGraphFromFile("TeLabels.ccbi");
//    CCDirector::sharedDirector()->replaceScene(CCTransitionFade::transitionWithDuration(2.0f, scene));
CCLog("1");
    
    CCNodeLoaderLibrary* ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
    CCLog("2");
    CCBReader* reader = new CCBReader(ccNodeLoaderLibrary);
    CCLog("3");
    CCNode* scene = reader->readNodeGraphFromFile("TestLabels.ccbi");
    CCLog("4");
    
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    scene->setPosition(ccp(size.width/2, size.height/2));
                                                  if(scene != NULL)
                                                  {
                                                      this->addChild(scene, 2);
                                                      scene->release();
                                                  }
    CCLog("5");
//#endif
}
示例#5
0
文件: Units.cpp 项目: cjlaaa/WarDemo
bool Unit::Init(enUnitType eType, enUnitIndex eIndex)
{
    do
    {
        unitDataMap unitData = GlobalData::sharedDirector()->getUnitDefaultData();
        m_unitData = unitData[eType];
        
        m_nFireCd = m_unitData.nFireCD;
        m_eUnitType = m_unitData.eType;
        m_eUnitStatus = enUnitStatusPre;
        m_nHp = m_unitData.nHp;
        m_eUnitIndex = eIndex;
        
        CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
        CCBReader * ccbReader = new CCBReader(ccNodeLoaderLibrary);
        CCNode * ccbNode = ccbReader->readNodeGraphFromFile(m_unitData.strCCBI.c_str(), this);
        m_animationManager = ccbReader->getAnimationManager();
        m_animationManager->runAnimationsForSequenceNamed("run");
        m_animationManager->setAnimationCompletedCallback(this, callfunc_selector(Unit::AnimationCallBack));
        ccbReader->release();
        
        addChild(ccbNode);
        return true;
    } while (false);
    CCLog("Function Unit::Init Error!");
    return false;
}
示例#6
0
void LayerChonBanChoi::onButtonCreate(CCObject* pSender)
{
    CCLOG("onButtonUpdate ");
    //Check
    boost::shared_ptr<double> am, amf;
    boost::shared_ptr<User> myself = GameServer::getSingleton().getSmartFox()->MySelf();
    if( myself==NULL || myself->GetVariable("am")==NULL || myself->GetVariable("amf")==NULL ){
        return;
    }
    amf = myself->GetVariable("amf")->GetDoubleValue();
    if((*amf/4)<1000){
		CCLOG("Không đủ tiền tạo phòng!");
		Chat *toast = new Chat("Bạn không đủ tiền tạo phòng!!", -1);
		this->addChild(toast);
        return;
    }
    
	CCNodeLoaderLibrary* ccNodeLoaderLibrary = SceneManager::getSingleton().getNodeLoaderLibrary();
	CCBReader* ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
    LayerCreateRoom* mLayer;
    if (ccbReader)
    {
        mLayer = (LayerCreateRoom *)ccbReader->readNodeGraphFromFile( "LayerCreateRoom.ccbi" );
        this->addChild(mLayer, 1, 1);
        ccbReader->release();
    }
    mLayer->setGameID(m_gID);
}
bool TitleScene::init()
{
    CCLOG("TitleScene::init()");
    if ( !Layer::init() )
    {
        return false;
    }
    // BGM・SEのプリロード
    SimpleAudioEngine::getInstance()->preloadBackgroundMusic(BGM_TITLE);
    SimpleAudioEngine::getInstance()->preloadEffect(SE_TOUCH_NORMAL);
    
    // タイトルのccbiファイルを読み込む
    auto nodeLoaderLibrary = NodeLoaderLibrary::getInstance();
    CCBReader* reader = new CCBReader(nodeLoaderLibrary);
    auto TitleNode = reader->readNodeGraphFromFile("ccbi/TitleScene.ccbi");
    
    // 追加
    this->addChild(TitleNode, 0);
    
    // 開放
    reader->release();
    
    // シングルタップのみ受付
    setTouchEnabled(true);
    setTouchMode(Touch::DispatchMode::ONE_BY_ONE);

    return true;
}
bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);
	
    // デザインサイズの設定
    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);

    CCSize frameSize = pEGLView->getFrameSize();

    std::vector<std::string> searchPath;

    if (frameSize.height > largeResource.size.height)
    {
        // iPad Retina用リソースを使用
        searchPath.push_back(xlargeResource.directory);
        pDirector->setContentScaleFactor(MIN(xlargeResource.size.height / designResolutionSize.height, xlargeResource.size.width / designResolutionSize.width));
    }
    else if (frameSize.height > smallResource.size.height)
    {
        // iPad用リソースを使用
        searchPath.push_back(largeResource.directory);
        pDirector->setContentScaleFactor(MIN(largeResource.size.height / designResolutionSize.height, largeResource.size.width / designResolutionSize.width));
    }
    else
    {
        // iPhone用リソースを使用
        searchPath.push_back(smallResource.directory);
        pDirector->setContentScaleFactor(MIN(smallResource.size.height / designResolutionSize.height, smallResource.size.width / designResolutionSize.width));
    }

    // リソースディレクトリを指定
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);

    // turn on display FPS
    pDirector->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);

    // CocosBuilderのファイルを読み込みゲーム画面を生成する
    CCNodeLoaderLibrary* ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
    ccNodeLoaderLibrary->registerCCNodeLoader("GameLayer", GameLayerLoader::loader());
    CCBReader* ccbReader = new CCBReader(ccNodeLoaderLibrary);
    CCNode* node = ccbReader->readNodeGraphFromFile("GameLayer.ccbi");
    ((GameLayer*)node)->setAnimationManager(ccbReader->getAnimationManager());

    // シーンを用意し、ゲーム画面を設置する
    CCScene* pScene = CCScene::create();
    if (node != NULL)
        pScene->addChild(node);
    ccbReader->release();

    // run
    pDirector->runWithScene(pScene);

    return true;
}
bool AppDelegate::applicationDidFinishLaunching()
{
    LoadFunc::registerLoader();
    
    // initialize director
    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());

    // turn on display FPS
    pDirector->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    pDirector->setAnimationInterval(1.0 / 60);
    
    // set game window siz(1024x577)
    CCEGLView::sharedOpenGLView()->setDesignResolutionSize(1024, 577, kResolutionShowAll);

    // create a scene. it's an autorelease object
    CCNodeLoaderLibrary* ccNodeLoaderLibrary = CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary();
    CCBReader * ccbReader = new CCBReader(ccNodeLoaderLibrary);
    CCNode* node = ccbReader->readNodeGraphFromFile("CollisionTestLayer.ccbi");
    
    CCScene *scene = CCScene::create();
    scene->addChild(node);
    
    CC_SAFE_DELETE(ccbReader);

    // run
    pDirector->runWithScene(scene);

    return true;
}
示例#10
0
bool HeroSkillLayer::init(){
    if ( !CCLayer::init() )
    {
        return false;
    }
    this->setTouchEnabled(true);
    this->setTouchPriority(-128);
    this->setTouchMode(kCCTouchesAllAtOnce);
    //加载cocosbuilder
    CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary()->registerCCNodeLoader("HeroSkillccbi",HeroSkillccbiLoder::loader());
    /* Create an autorelease CCBReader. */
    CCBReader * ccbReader = new cocos2d::extension::CCBReader(CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary());
    ccbReader->autorelease();
    /* Read a ccbi file. */
    node2 = ccbReader->readNodeGraphFromFile("ccbi/HeroSkillccbi.ccbi", this);
    if(node2 != NULL) {
        this->addChild(node2);
    }
    this->setVisible(false);
    isSkillLayer = true;
    layervisable = false;
    curPage = 0;//当前页
    addsprite();
    changeData();
    scheduleUpdate();
    return true;
}
示例#11
0
// Constructor for the enemy. The layer is initialized in Model's constructor.
Enemy::Enemy(int x, int y) : Model(x,y)
{
    // Create a default NodeLoaderLibrary.
    NodeLoaderLibrary* nodeLoaderLibrary;
    nodeLoaderLibrary = NodeLoaderLibrary::newDefaultNodeLoaderLibrary();
    
    // Create a new CCBReader with a default NodeLoaderLibrary
    // This can take a lot of parameters to use code connections and more
    CCBReader* ccbReader = new CCBReader(nodeLoaderLibrary);
    
    // Load the main node from the CocosBuilder file
    modelNodes = ccbReader->readNodeGraphFromFile("Orc.ccbi");
    
    // Get the animationmanager so we can animate the thing afterwards
    animationManager = ccbReader->getAnimationManager();
    modelNodes->setPosition( Point(x, y));
    //modelNodes->setScale(0.5f);
    
    Node* rShoulder = modelNodes->getChildByTag(1)->getChildByTag(4)->getChildByTag(1);
    rShoulder->setZOrder(0);
    Node* lHip = modelNodes->getChildByTag(1)->getChildByTag(1);
    lHip->setZOrder(0);
    Node* rHip = modelNodes->getChildByTag(1)->getChildByTag(2);
    rHip->setZOrder(0);
    Node* rUpperArm = rShoulder->getChildByTag(2);
    rUpperArm->setZOrder(-1);
    Node* chest = modelNodes->getChildByTag(1)->getChildByTag(4)->getChildByTag(2);
    chest->setZOrder(0);
    Node* hips = modelNodes->getChildByTag(1)->getChildByTag(3);
    hips->setZOrder(0);
    modelNodes->getChildByTag(1)->getChildByTag(4)->setZOrder(0);
    
    Node* lShoulder = modelNodes->getChildByTag(1)->getChildByTag(4)->getChildByTag(4);
    lShoulder->setZOrder(3);
    Node* rElbow = rShoulder->getChildByTag(1);
    rElbow->setZOrder(1);
    Node* rLowerArm = rShoulder->getChildByTag(1)->getChildByTag(1);
    rLowerArm->setZOrder(2);
    Node* rHand = rShoulder->getChildByTag(1)->getChildByTag(2);
    rHand->getChildByTag(1)->setVisible(true);
    rHand->setZOrder(2);
    
    Node* neck = modelNodes->getChildByTag(1)->getChildByTag(4)->getChildByTag(3);
    neck->setZOrder(2);
    
    
    this->addChild(modelNodes); // Add the loaded node to the scene (this)
    
    healthStatus->setPosition(Point(x-500, y+100));
    this->addChild(healthStatus);
    
    initAttacks();
    
    // As nobody called ccbReader->autoRelease(), returning now would cause
    // a memory leak. We can call autoRelease or delete it ourselves.
    delete ccbReader;
    
}
示例#12
0
//---------------------------------------
//	カスタムクラスのパーツの取得(クラス名指定あり)
//---------------------------------------
CCNode* SceneChanger::loadCustomParts(const char* className, const char* fileName, CCNodeLoader* loader) {
    CCNodeLoaderLibrary* ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
    ccNodeLoaderLibrary->registerCCNodeLoader(className, loader);
    CCBReader* ccbReader = new CCBReader(ccNodeLoaderLibrary);
    CCString* file = CCString::createWithFormat("%s.ccbi", fileName);
    CCNode* node = ccbReader->readNodeGraphFromFile(file->getCString());
    ccbReader->release();
    return node;
}
示例#13
0
bool BalloonRankDialog::init()
{
	bool bRet = false;
	do
	{
		CC_BREAK_IF(!DialogLayer::init());
		CCNodeLoaderLibrary* pLoaderLib = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();

		CCBReader* pCCBReader = new CCBReader(pLoaderLib);

		std::string strCCBFileName = "BalloonRankDialog.ccbi";

		const std::vector<std::string> vSearchOrder = CCFileUtils::sharedFileUtils()->getSearchResolutionsOrder();

		std::string strCCBRootPath = vSearchOrder[0];

		pCCBReader->setCCBRootPath(strCCBRootPath.c_str());

		CCNode* pNode = pCCBReader->readNodeGraphFromFile(strCCBFileName.c_str(), this);

		if (pNode != NULL)
		{
			this->addChild(pNode);
		}

		pCCBReader->release();
		
		setKeypadEnabled(true);

		initLabelTTF();
        
        initTableView();
        
        initMenu();
        
        // start fire
        CCArray* pArrayFire = CCArray::createWithCapacity(6);
        for (int idx = 1; idx <= 6; ++idx)
        {
            pArrayFire->addObject(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(CCString::createWithFormat("energy_fire%d.png", idx)->getCString()));
        }
        CCAnimation* pAnimation = CCAnimation::createWithSpriteFrames(pArrayFire, 0.1f);
        CCAnimate* pAnimateFire = CCAnimate::create(pAnimation);
        m_pSpriteScoreFire->runAction(CCRepeatForever::create(pAnimateFire));
        
        // set animation onEnter and onExit
        m_pMainBoard = m_pSpriteBoard;
        m_pSpriteBoard->setScale(0.01f);
        setOnEnterAction(CCEaseBounceOut::create(CCScaleTo::create(0.5f, 1.0f)));
        setOnExitAction(CCEaseExponentialIn::create(CCScaleTo::create(0.5f, 0.01f)));
		
		bRet = true;
		
	} while(0);
	
	return bRet;
}
示例#14
0
bool CResultDlg::init()
{
    CCLayer::init() ;
    CCNodeLoaderLibrary* plib = CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary() ;
    CCBReader* pread = new CCBReader(plib);
    CCNode* pnode = pread->readNodeGraphFromFile("ResultDlg.ccbi", this) ;
    addChild(pnode) ;
    return true ;
}
示例#15
0
Node *CCBHelper::createSimpleCCBLayer(const char *ccbFileName, Object* pOwner)
{
	NodeLoaderLibrary *loaderLibrary = NodeLoaderLibrary::newDefaultNodeLoaderLibrary();

	CCBReader *reader = new CCBReader(loaderLibrary);	// library, memberAssigner, selectorResolver
	Node *node = reader->readNodeGraphFromFile(ccbFileName, pOwner);
	delete reader;
	
	return node;
}
示例#16
0
void BattleScene::initPauseLayer(){
    CCNodeLoaderLibrary *nodeLoaderLibrary = CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary();
    CCBReader *reader = new CCBReader(nodeLoaderLibrary);
    
    pauseLayer = (PauseLayer *)reader->readNodeGraphFromFile("BattleScenePauseMenu.ccbi", this);
    pauseLayer->setBattleLayer(battleLayer);
    pauseLayer->hide();
    this->addChild(pauseLayer, PAUSE_LAYER_Z);
    
    reader->release();
}
// load ccnode from ccbi
CCNode* CCBLoaderManager::LoadFromCCBI(CCNodeLoader* loader, const char* className, const char* ccbFileName)
{
	CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary();
	ccNodeLoaderLibrary->registerCCNodeLoader(className, loader);
	CCBReader* ccbReader = new CCBReader(ccNodeLoaderLibrary);
	std::string path = "ccbi/";
	path.append(ccbFileName);
	CCNode* node = ccbReader->readNodeGraphFromFile(path.c_str());
    delete ccbReader;
	return node;
}
示例#18
0
FruitObject* FruitObject::node(const char *ccbName,int color)
{
    CCNodeLoaderLibrary *nodeLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
    nodeLibrary->registerCCNodeLoader("FruitObject", FruitObjectLoader::loader());
    CCBReader *ccbReader = new CCBReader(nodeLibrary);
    FruitObject *node1 = (FruitObject *)ccbReader->readNodeGraphFromFile(ccbName);
    node1->color = color;
    node1->choose = false;
    
//    ccbReader->release();
    return node1;
}
示例#19
0
bool GameDisplayNode::initWithDictionary(CCDictionary * tmpDict){
	
	CCNode * _displayNode = NULL;
	if (tmpDict) {
		CCString * strValue = (CCString *)tmpDict->objectForKey(KStrType);
		uint32_t typeValue = strValue->uintValue();
		strValue = (CCString *)tmpDict->objectForKey(KStrFile);
		switch (typeValue) {
			case GameObject::K_SPRITE_FRAME:
			{
				_displayNode = CCSprite::createWithSpriteFrameName(strValue->getCString());
				this->addChild(_displayNode);
				_defaultFrame = strValue->getCString();
			}
				break;
			case GameObject::K_SPRITE_FILE:
			{
				_displayNode = CCSprite::create(strValue->getCString());
				this->addChild(_displayNode);
				_defaultFrame = strValue->getCString();
			}
				break;
			case GameObject::K_CCBI_FILE:
			{
				//动画加载
				CC_SAFE_RELEASE_NULL(_animationManager);
				string ccbifile = strValue->getCString();
				CCNodeLoaderLibrary *ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
				CCBReader * ccBReader = new CCBReader(ccNodeLoaderLibrary);
				_displayNode = ccBReader->readNodeGraphFromFile(ccbifile.c_str(),this,&_animationManager);
				_animationManager->retain();
				_animationManager->setDelegate(this);
				this->addChild(_displayNode);
				CC_SAFE_RELEASE_NULL(ccBReader);
				
				CCString * default_frame = (CCString *)tmpDict->objectForKey(KStrDefaultFrame);
				if (default_frame) {
					_defaultFrame = default_frame->getCString();
				}
				
				CCString * default_anim=(CCString *)tmpDict->objectForKey(KStrDefaultAnim);
				if (default_anim) {
					_defaultAnimation = default_anim->getCString();
				}
			}
				break;
			default:
				break;
		}
	}
	return true;
}
示例#20
0
void LayerFriend::gotoFriendDetails(){
    removeOldView();
	CCNodeLoaderLibrary* ccNodeLoaderLibrary = SceneManager::getSingleton().getNodeLoaderLibrary();
	CCBReader* ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
    LayerFriendDetails* mLayer;
    if (ccbReader)
    {
        mLayer = (LayerFriendDetails *)ccbReader->readNodeGraphFromFile( "LayerFriendDetails.ccbi" );
        nodeChild->addChild(mLayer, 1, 1);
        ccbReader->release();
    }
    currNodeView = mLayer;
}
示例#21
0
void Bomb::handleCollisionWith(GameObject *gameObject)
{
    if (dynamic_cast<Dragon*>(gameObject)) {
        // Collided with the dragon, remove object and add an explosion instead.
        this->setIsScheduledForRemove(true);
        
        CCNodeLoaderLibrary* ccNodeLoaderLibrary = CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary();
        CCBReader* ccbReader = new CCBReader(ccNodeLoaderLibrary);
        CCNode* pExplosion = ccbReader->readNodeGraphFromFile("Explosion.ccbi");
        pExplosion->setPosition(this->getPosition());
        this->getParent()->addChild(pExplosion);
        ccbReader->release();
    }
}
示例#22
0
//void MapMenu1Layer::tableCB( CCObject* pObject )
//{
//    CCMenuItemImage *mi = (CCMenuItemImage*)pObject;
//    int tag = mi->getTag();
//    switch (tag) {
//        case 1:
//            m_table1->setVisible(true);
//            m_table2->setVisible(false);
//            break;
//        case 2:
//            m_table1->setVisible(false);
//            m_table2->setVisible(true);
//            break;
//        default:
//            break;
//    }
//}
void MapMenu1Layer::loadCCBFile(int i)
{
    CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary()->registerCCNodeLoader( "ReviewLayer", ReviewLayerLoader::loader());
    CCBReader* reader = new CCBReader( CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary() );
    reader->autorelease();
    
    
    char str[255];
    sprintf(str,"wkszReview/ReviewLayer%d.ccbi",i);
    CCNode* node = reader->readNodeGraphFromFile(str);
    this->getParent()->addChild(node);
    
    this->closeCB(NULL);
}
示例#23
0
void LayerButtonInGame::eventTouchBtnSetting(CCObject *pObject, TouchEventType pType){
	if (pType == TOUCH_EVENT_ENDED){
		CCLOG("Click Setting");
		CCNodeLoaderLibrary* ccNodeLoaderLibrary = SceneManager::getSingleton().getNodeLoaderLibrary();
		CCBReader* ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
		LayerSettings* mLayerSettings;
		if (ccbReader)
		{
			mLayerSettings = (LayerSettings *)ccbReader->readNodeGraphFromFile( "LayerSettings.ccbi" );
			SceneManager::getSingleton().getLayerOnTop()->addChild(mLayerSettings, 1, 1);
			ccbReader->release();
		}
	}
}
示例#24
0
Bomb* Bomb::bomb()
{
    CCNodeLoaderLibrary *nodeLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
    nodeLibrary->registerCCNodeLoader("Bomb", BombLoader::loader());
    CCBReader *ccbReader = new CCBReader(nodeLibrary);
    Bomb *node = (Bomb *)ccbReader->readNodeGraphFromFile("ccb/bomb");
    ccbReader->getAnimationManager()->setAnimationCompletedCallback(node, callfunc_selector(Bomb::test));
    ccbReader->release();
    
//    CCBAnimationManager * ccbManager = (CCBAnimationManager *)node->getUserObject();
//    ccbManager->setAnimationCompletedCallback(node, callfunc_selector(Bomb::test));
    
    return node;
}
示例#25
0
CCNode* AbstractNodeProvider::getNodeFromCcbFile(const char* pCcbFileName) {
    CCBReader* pReader = new CCBReader(CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary());
    pReader->setCCBResourcePostfix(getResourcePostfix());
	CCNode* pNode = pReader->readNodeGraphFromFile(pCcbFileName);

    AnimationManagerAssigner *pAnimationManagerAssigner = dynamic_cast<AnimationManagerAssigner *>(pNode);
    if (pAnimationManagerAssigner != NULL) {
        pAnimationManagerAssigner->setAnimationManagers(pReader->getAnimationManagers());
    }

	pReader->release();

	return pNode;
}
示例#26
0
bool CLoginLayer::init()
{
    CCLayer::init() ;
    m_pAccount = m_pPassWord = NULL ;
    CCNodeLoaderLibrary* pLiberay =  CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary() ;
    CCBReader* pReader =  new CCBReader(pLiberay);
    CCNode* pnode = pReader->readNodeGraphFromFile("UIScene/Login.ccbi", this) ;
    addChild(pnode) ;
    pReader->release() ;
//    CCSprite* pgirl = CCSprite::create("iphone/linkingscene_logo.png") ;
//    pgirl->setAnchorPoint(ccp(0,0));
//    pgirl->setPosition(ccp(8.0,-7));
//    addChild(pgirl) ;
    return true ;
}
示例#27
0
bool SelectRoomLayer::init()
{
    CCLayer::init();
    CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
    
    CCBReader* pReader = new CCBReader(ccNodeLoaderLibrary);
    float fHfactor = 320.0 / CCDirector::sharedDirector()->getWinSize().height ;
    float fWfactor = 480.0 / CCDirector::sharedDirector()->getWinSize().width ;
    float fCCBResoulution = 1.0 / (fHfactor > fWfactor ? fHfactor :fWfactor) ;
    pReader->setResolutionScale(fCCBResoulution ) ;
    CCNode* pRoot = pReader->readNodeGraphFromFile("ccbi/SelectRoomLayer.ccbi", this) ;
    addChild(pRoot) ;
    
    return true ;
}
示例#28
0
void LiquidScene::tappedPreviousButton(Object* pSender, Control::EventType pControlEventType)
{
    CCLOG("tappedPreviousButton eventType = %d", pControlEventType);
    NodeLoaderLibrary* nodeLoaderLibrary = NodeLoaderLibrary::getInstance();
    nodeLoaderLibrary->registerNodeLoader("OpeningLayer", OpeningLayerLoader::loader());
    CCBReader* ccbReader = new CCBReader(nodeLoaderLibrary);
    Node* node = ccbReader->readNodeGraphFromFile("Opening.ccbi");
    Scene* scene = Scene::create();
    if (node != NULL)
    {
        scene->addChild(node);
    }
    ccbReader->release();
    Director::getInstance()->replaceScene(scene);
}
示例#29
0
MenuScene *MenuSceneLoader::load()
{
    CCNodeLoaderLibrary *lib = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary();
    lib->registerCCNodeLoader("MenuScene", MenuSceneLoader::loader());
    
    CCBReader *reader = new CCBReader(lib);
    
    reader->autorelease();
    
    CCNode *node = reader->readNodeGraphFromFile("MenuScene.ccbi");
    

    return (MenuScene*)node;
    
}
示例#30
0
void LayerFriend::gotoInviteFriends(){
   
	CCNodeLoaderLibrary* ccNodeLoaderLibrary = SceneManager::getSingleton().getNodeLoaderLibrary();
	CCBReader* ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
	ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary);
	LayerInviteFriends* mLayer;
	if (ccbReader)
	{
		mLayer = (LayerInviteFriends *)ccbReader->readNodeGraphFromFile( "LayerInviteFriends.ccbi" );
		nodeChild->getParent()->addChild(mLayer, 1, 1);
		ccbReader->release();
		mLayer->setZOrder(INT_MAX);
	}
   

}