コード例 #1
0
CCTableViewCell* HelloWorld::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
    CCDictionary* pRecipe = (CCDictionary*)m_pRecipes->objectAtIndex(idx);
    CCString* pName = (CCString*)pRecipe->objectForKey("name");
    CCString* pNo   = (CCString*)pRecipe->objectForKey("recipe");
    CCString* pStep = (CCString*)pRecipe->objectForKey("step");
    
    CCString* string;
    if (pStep!=NULL) {
        string = CCString::createWithFormat("レシピ %s (ステップ%s): %s", pNo->getCString(), pStep->getCString(), pName->getCString());
    } else if (pNo->isEqual(CCString::create("0"))) {
        string = pName;
    } else {
        string = CCString::createWithFormat("レシピ %s : %s", pNo->getCString(), pName->getCString());
    }
    CCTableViewCell *cell = table->dequeueCell();
    if (!cell) {
        cell = new CCTableViewCell();
        cell->autorelease();
        
        CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
        
        int fontSize = CCEGLView::sharedOpenGLView()->getDesignResolutionSize().height/320.0f * 20;
        CCLabelTTF *label = CCLabelTTF::create(string->getCString(), "Helvetica", fontSize, CCSizeMake(visibleSize.width, visibleSize.height/5), kCCTextAlignmentCenter);
        label->setPosition(CCPointZero);
		label->setAnchorPoint(CCPointZero);
        label->setTag(123);
        cell->addChild(label);
    }
    else
    {
        CCLabelTTF *label = (CCLabelTTF*)cell->getChildByTag(123);
        label->setString(string->getCString());
    }
    
    
    return cell;
}
コード例 #2
0
    void textHandler(void *ctx, const char *ch, int len)
    {
        CC_UNUSED_PARAM(ctx);
        if (m_tState == SAX_NONE)
        {
            return;
        }

        CCSAXState curState = m_tStateStack.empty() ? SAX_DICT : m_tStateStack.top();
        CCString *pText = new CCString();
        pText->m_sString = std::string((char*)ch,0,len);

        switch(m_tState)
        {
        case SAX_KEY:
            m_sCurKey = pText->m_sString;
            break;
        case SAX_INT:
        case SAX_REAL:
        case SAX_STRING:
            {
                CCAssert(!m_sCurKey.empty(), "not found key : <integet/real>");

                if (SAX_ARRAY == curState)
                {
                    m_pArray->addObject(pText);
                }
                else if (SAX_DICT == curState)
                {
                    m_pCurDict->setObject(pText, m_sCurKey);
                }
                break;
            }
        default:
            break;
        }
        pText->release();
    }
コード例 #3
0
ファイル: GameScene.cpp プロジェクト: shinriyo/expeller
// do not move to Player.h
void Game::setPlayerPosition(CCPoint position, CCFiniteTimeAction* sequence)
{
    CCPoint tileCoord = this->tileCoordForPosition(position);
    int tileGid = _meta->tileGIDAt(tileCoord);
    
    if (tileGid) {
        CCDictionary *properties = _tileMap->propertiesForGID(tileGid);
        if (properties) {
            // obstacle
            CCString *collision = new CCString();
            *collision = *properties->valueForKey("Collidable");
            // Moveable
            CCString *move = new CCString();
            *move = *properties->valueForKey("Moveable");
            // Breakable
            CCString *breakable = new CCString();
            *breakable = *properties->valueForKey("Breakable");
            
            if ((collision && collision->compare("True") == 0) ||
                 (move && move->compare("True") == 0) ||
                 (breakable && breakable->compare("True") == 0)) {
                // 動けない音を出す
                CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("hit.caf");
                this->finishAnimation();
                CCLog("Can't move");
                return;
            }
            
            // item get
            CCString *collectable = new CCString();
            
            *collectable = *properties->valueForKey("Collectable");
            if (collectable && (collectable->compare("True") == 0)) {
                // 取り除く
                _meta->removeTileAt(tileCoord);
                _foreground->removeTileAt(tileCoord);
                _numCollected++;
                _hud->numCollectedChanged(_numCollected);
                CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("pickup.caf");
            }
        }
    }
    
    _player->runAction(sequence);
    // not hit only 赤にする
    this->setTileEffect(position);
    CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("move.caf");
}
コード例 #4
0
ファイル: SkillEffectShow.cpp プロジェクト: mofr123/game
void SkillEffectShow::playCasterSpecific(const char *path)
{
	Figure* figure = ((Monomer*)m_attacker->getParent())->getFigure();

	if (figure->getWeaponSprite() == NULL)
		return;

	Sprite* sprite = Sprite::create();
	sprite->setPosition(figure->getWeaponSprite()->getContentSize()/2);
	figure->getWeaponSprite()->addChild(sprite);

	//CCArray* array = CCArray::createWithCapacity(4);
	Vector<SpriteFrame*> array ;
	int flag = 0;

	do
	{
		CCString* string = CCString::createWithFormat("%s_%d0_%02d.png", path, figure->getDirectionType(), flag);
		SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->spriteFrameByName(string->getCString());
		CC_BREAK_IF(spriteFrame == NULL);
		array.pushBack(spriteFrame);
		flag++;
	}
	while (1);

	if (array.size() > 0)
	{
		Animation* movie = Animation::createWithSpriteFrames(array, 1 / (float)10);
		Animate* animate = Animate::create(movie);
		CallFunc* callFunc = CallFunc::create(sprite, callfunc_selector(Sprite::removeFromParent));
		Sequence* actions = Sequence::create(animate, callFunc, NULL);
		sprite->runAction(actions);
	}
	else
	{
		sprite->removeFromParent();
	}
}
コード例 #5
0
InputLabel::InputLabel(const char* placeHolder, const char* fontName, int fontSize, Vec2 location, ui::EditBox::InputMode inputMode, int maxChar, Size dimensions, TextHAlignment format)
{
    linkTo = NULL;
    isOpened = false;
    textDirty = false;
    originalInfos = NULL;
    isPassword = false;
    passwordText = NULL;
    name = placeHolder;
    ui::Scale9Sprite* sprite = ui::Scale9Sprite::create("green_edit.png", Rect(0, 0, 43, 38), Rect(4, 3, 35, 32));
    sprite->setPreferredSize(Size(43, 38));
    sprite->setOpacity(0);
    delegate = ui::EditBox::create(dimensions, sprite);
    delegate->retain();
    if(strlen(placeHolder) > 0)
    {
        CCString* placeholderWithBrackets = ScreateF("<%s>", placeHolder);
        delegate->setPlaceHolder(placeholderWithBrackets->getCString());
        this->setInitialText(placeholderWithBrackets);
    }
    delegate->setFontColor(Color3B::BLACK);
    delegate->setDelegate(this);
    
    this->setPosition(location);
    delegate->setInputMode(inputMode);
    numbersOnly = inputMode ==  ui::EditBox::InputMode::DECIMAL;
    delegate->setReturnType(ui::EditBox::KeyboardReturnType::DONE);
    delegate->setInputFlag(ui::EditBox::InputFlag::INITIAL_CAPS_SENTENCE);
    if(maxChar != -1)
    {
        delegate->setMaxLength(maxChar);
    }
    listeners.pushBack(Director::getInstance()->getEventDispatcher()->addCustomEventListener("OpenKeyboard", std::bind(&InputLabel::openKeyboard, this, std::placeholders::_1)));
    listeners.pushBack(Director::getInstance()->getEventDispatcher()->addCustomEventListener("CloseKeyboard", std::bind(&InputLabel::closeKeyboard, this, std::placeholders::_1)));
    listeners.pushBack(Director::getInstance()->getEventDispatcher()->addCustomEventListener("DisableInputs", std::bind(&InputLabel::disableInputs, this, std::placeholders::_1)));
    listeners.pushBack(Director::getInstance()->getEventDispatcher()->addCustomEventListener("EnableInputs", std::bind(&InputLabel::enableInputs, this, std::placeholders::_1)));
    
}
コード例 #6
0
ファイル: S3TestScene.cpp プロジェクト: liuyuyefz/GreTest
CCTableViewCell* S3TestMain::tableCellAtIndex(CCTableView *table, unsigned int idx)
{
//    CCString *strCell = CCString::createWithFormat("Practice %d",idx);
    CCString *strCell = CCString::create(aVectorCellValue[idx].c_str());
    CCTableViewCell *pCell = table->dequeueCell();
    if (!pCell) {
        pCell = new CCTableViewCell();
        pCell->autorelease();
        CCSprite *pSprite = CCSprite::create();//("cellLine.png");
        pSprite->setAnchorPoint(CCPointZero);
		pSprite->setPosition(CCPointZero);
        pCell->addChild(pSprite);
        
        {
            CCLabelTTF *pLabel = CCLabelTTF::create(strCell->getCString(), "Arial", s3FontSize3_macro, s3Size2_macro(aCell), kCCTextAlignmentLeft, kCCVerticalTextAlignmentCenter);
            pLabel->setPosition(ccp(s3Less2_macro,0));
            pLabel->setAnchorPoint(CCPointZero);
            pLabel->setColor(ccc3(0,0,0));
            pLabel->setTag(10);
            pCell->addChild(pLabel,1);
        }
        
        {
            CCLabelTTF *pLabel = CCLabelTTF::create("Locked", "Arial",s3FontSize3_macro, s3Size3_macro(aItem), kCCTextAlignmentRight, kCCVerticalTextAlignmentCenter);
            pLabel->setPosition(s3Position8_macro(aItem));
            pLabel->setAnchorPoint(CCPointZero);
            pLabel->setColor(ccc3(0,0,255));
            pLabel->setTag(10);
            pCell->addChild(pLabel,1);
        }
        
    }
    
    CCLabelTTF *pLabel = (CCLabelTTF*)pCell->getChildByTag(10);
    pLabel->setString(strCell->getCString());
    
    return pCell;
}
コード例 #7
0
ファイル: SFActionInstant.cpp プロジェクト: moky/SpriteForest
CCAction * SFCallFuncO::ccAction(void)
{
	CCObject * pTargetCallback = getTargetCallback();
	CCString * pSelector = getSelector();
	if (!pTargetCallback || !pSelector)
	{
		CNLog("error");
		return NULL;
	}
	CNSelectorDelegate * pCallback = dynamic_cast<CNSelectorDelegate *>(pTargetCallback);
	if (!pCallback)
	{
		CNLog("cannot get selector: %s", pSelector->getCString());
		return NULL;
	}
	SEL_CallFuncO selector = pCallback->getSelectorO(pSelector->getCString());
	if (!selector)
	{
		CNLog("no such selector: %s", pSelector->getCString());
		return NULL;
	}
	return CCCallFuncO::actionWithTarget(pTargetCallback, selector, m_pObject);
}
コード例 #8
0
Price createPriceWithDictionary(CCDictionary * dict)
{
	Price::CoinType coinType;
	uint32 value;
	
	CCString * strType = (CCString *)dict->objectForKey(PRICE_TYPE_KEY);
	if (strType->compare(PRICE_COIN) == 0)
	{
		coinType = Price::kCoinType_Coin;
	}
	else if (strType->compare(PRICE_GEM) == 0)
	{
		coinType = Price::kCoinType_Gem;
	}
	else
	{
		coinType = Price::kCoinType_Unknown;
	}
	
	CCString * strNumber = (CCString *)dict->objectForKey(PRICE_VALUE_KEY);
	value = strNumber->uintValue();
	return Price(coinType, value);
}
コード例 #9
0
ファイル: Recipe15.cpp プロジェクト: n1ck0g0m3z/GameRecipe
void Recipe15::eat(float delta)
{
	CCSprite* player = (CCSprite*) this->getChildByTag(1);
	player->setTexture(CCTextureCache::sharedTextureCache()->addImage("monkey01.png"));

	CCSize winSize = CCDirector::sharedDirector()->getWinSize();

	this->m_points += player->getPositionX()/(winSize.width/4) + 1;

	CCLabelTTF* label = (CCLabelTTF*)this->getChildByTag(11);

	CCString* points = CCString::createWithFormat("%d", this->m_points);

	label->setString(points->getCString());

	CCAnimationCache* cache = CCAnimationCache::sharedAnimationCache();
	cache->addAnimationsWithFile("animations.plist");

	CCAnimation* animation2 = cache->animationByName("bite");

	CCAnimate* action = CCAnimate::create(animation2);
	player->runAction(action);
}
コード例 #10
0
void AnimationManager::createSoulIcon(int soul, CCPoint point){
    CCString *string = CCString::createWithFormat("+%i", soul);
    CCLabelTTF *soulGainLabel = CCLabelTTF::create(string->getCString(), Main_Font, 128);
    soulGainLabel->setColor(ccMAGENTA);

    LabelWrapper *labelWrapper = new LabelWrapper();
    labelWrapper->initWithLabel(soulGainLabel);
    labelWrapper->setPosition(point);
    GM->gameLayer->addChild(labelWrapper, 1000000);
    //    CCScaleTo *action = CCScaleTo::create(.05, .4);
    //    CCEaseIn *ease = CCEaseIn::create(action, 1.0);
    CCDelayTime *delay = CCDelayTime::create(.8);
    CCFadeOut *fade = CCFadeOut::create(.4);
    CCCallFunc *obj = CCCallFunc::create(labelWrapper, callfunc_selector(BaseObject::removeBaseObject));
    
    CCSequence *seq = CCSequence::create( delay, fade, obj, NULL);
    labelWrapper->runAction(seq);
    /*    AnimationObject *animationObject = new AnimationObject();
     animationObject->init(seq, icon);
     animationObject->duration = .04;*/
    
    //this->addAnimation(animationObject);
}
コード例 #11
0
ファイル: RankUp.cpp プロジェクト: playdandi/CocoDrawingMagic
void RankUp::Notification(CCObject* obj)
{
    CCString* param = (CCString*)obj;

    if (param->intValue() == 5)
    {
        // 자랑하기 블록
        ((CCSprite*)spriteClass->FindSpriteByName("button/btn_red_mini.png1"))->setColor(ccc3(150,150,150));
        ((CCSprite*)spriteClass->FindSpriteByName("letter/letter_boast.png"))->setColor(ccc3(150,150,150));
        isBoasted = true;
    }

    else if (param->intValue() == 10)
    {
        // 터치 풀기 (백그라운드에서 돌아올 때)
        isTouched = false;
        if (idx > -1)
        {
            spriteClass->spriteObj[idx]->sprite->setColor(ccc3(255,255,255));
            ((CCSprite*)spriteClass->FindSpriteByName("letter/letter_confirm_mini.png"))->setColor(ccc3(255,255,255));
        }
    }
}
コード例 #12
0
ファイル: CCNodeLoader.cpp プロジェクト: 1901/CCDate
CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) {
    CCString * animationFile = pCCBReader->readCachedString();
    CCString * animation = pCCBReader->readCachedString();
    
    CCAnimation * ccAnimation = NULL;
    
    // Support for stripping relative file paths, since ios doesn't currently
    // know what to do with them, since its pulling from bundle.
    // Eventually this should be handled by a client side asset manager
    // interface which figured out what resources to load.
    // TODO Does this problem exist in C++?
    animation = CCBReader::lastPathComponent(animation);
    animationFile = CCBReader::lastPathComponent(animationFile);
    
    if (animation != NULL && animation->compare("") != 0) 
    {
        CCAnimationCache * animationCache = CCAnimationCache::sharedAnimationCache();
        animationCache->addAnimationsWithFile(animationFile->getCString());
        
        ccAnimation = animationCache->animationByName(animation->getCString());
    }
    return ccAnimation;
}
コード例 #13
0
ファイル: CPreLoad.cpp プロジェクト: marszaya/huihe
int CCPreLoad::fetchNext()
{
	if(!m_dict)
		return -1;

	if(m_tmpIdx >= (int)m_dict->count() - 1)
		return 0; 

	if(!m_tmpKeyArr && initFetch()!=0)
	{
		return -1;
	}

	++m_tmpIdx;

	CCString* p = dynamic_cast<CCString*>(m_tmpKeyArr->objectAtIndex(m_tmpIdx));
	if(!p)
		return -1;	
	
	m_tmpFileName = p->getCString();

	return 1;
}
コード例 #14
0
ファイル: CCTMXLayer.cpp プロジェクト: alexzzp/cocos2dx-wince
	void CCTMXLayer::parseInternalProperties()
	{
		// if cc_vertex=automatic, then tiles will be rendered using vertexz

		CCString *vertexz = propertyNamed("cc_vertexz");
		if( vertexz ) 
		{
			if( vertexz->m_sString == "automatic" )
			{
				m_bUseAutomaticVertexZ = true;
			}
			else
			{
				m_nVertexZvalue = vertexz->toInt();
			}
		}

		CCString *alphaFuncVal = propertyNamed("cc_alpha_func");
		if (alphaFuncVal)
		{
			m_fAlphaFuncValue = alphaFuncVal->toFloat();
		}
	}
コード例 #15
0
bool KechengController::updateKecheng(bool isWin){
    Kecheng* kecheng=new Kecheng();
    kecheng->setIntid(0);
    kecheng->setIntwin(0);
    kecheng->setIntlose(0);
    S_DM->getByKey(kecheng, m_kcid);
    
    if (isWin) {
        kecheng->setIntwin(kecheng->getwin()+1);
    }else{
        kecheng->setIntlose(kecheng->getlose()+1);
    }
    
    CCString* sql;
    int now=(int)(TimeUtils::millisecondNow().tv_sec);
    if (kecheng->getid()==0) {
        sql=CCString::createWithFormat("insert into kecheng(id,win,lose,lastTime) values(%d,%d,%d,%d)",m_kcid,kecheng->getwin(),kecheng->getlose(),now);
    }else{
        sql=CCString::createWithFormat("update kecheng set win=%d,lose=%d,lastTime=%d where id=%d",m_kcid,kecheng->getwin(),kecheng->getlose(),now);
    }
    CC_SAFE_DELETE(kecheng);
    return S_DM->executeSql(sql->getCString());
}
コード例 #16
0
ファイル: GameLayer.cpp プロジェクト: ituaijagbone/SkyDefense
//start
void GameLayer::resetGame(void) {
    _score = 0;
    _energy = 0;
    
    // Reset timers and "speeds"
    _meteorInterval = 2.5;
    _meteorTimer = _meteorInterval * 0.99f;
    _meteorSpeed = 10;
    _healthInterval = 20;
    _healthTimer = 0;
    _healthSpeed = 15;
    
    _difficultyInterval = 60;
    _difficultyTimer = 0;
    
    _running = true;
    
    CCString * value = CCString::createWithFormat("%i%s", _energy, "%");
    _energyDisplay->setString(value->getCString());
    
    value = CCString::createWithFormat("%i", _score);
    _scoreDisplay->setString(value->getCString());
}
コード例 #17
0
ファイル: BackPack.cpp プロジェクト: brandav/CPlusPlus_Code
int BackPack::getItmDice(const char* filename)
{
  // return dice bonus amount
	CCString* nameCheck;
	//CCLog("filename is %s",filename);
	
	// run loop to find matching filename in m_asItems
	for (int i=0 ; i < sizeof(m_asItems)/TOTAL_ITEMS ; i++) // divide by the size of the struct to get length
	{
		nameCheck = CCString::createWithFormat("%s",m_asItems[i].filename);
		//CCLog("%s",m_asItems[i].filename);
		//if (m_asItems[i].filename == NULL || m_asItems[i].stock == 0);
		
		// use compare fxn for strings
		if (nameCheck->compare(filename) == 0)
		{
			//CCLog("got a match");
			// return dice number
			return m_asItems[i].dice;
		}
	}
	return NULL;
}
コード例 #18
0
ファイル: Enemy.cpp プロジェクト: ourgames/dc208
bool OutsideEnemy::init()
{
    mIcon = "c010";
    if(mEnemyType == ENEMY_TYPE_WILDMAN)
    {
        mIcon = "c010";
    }
    CCString* filePath = CCString::createWithFormat("%s_%d_%s_move_0.png", mIcon.c_str(), 0, "NW"); // guo.jiang
    if(CCLoadSprite::getSF(filePath->getCString())==NULL){
        CCLOG("filePath=%s",filePath->getCString());
    }
    mShadowSpr = CCLoadSprite::createSprite("walker_shadow.png");
    mShadowSpr->setAnchorPoint(ccp(0.5, 0.5));
    mShadowSpr->setOpacity(127);
    mShadowSpr->setScale(0.5);
    mBatchNode->addChild(mShadowSpr);
    
    mIconSpr = CCLoadSprite::createSprite(filePath->getCString());
    mIconSpr->setAnchorPoint(ccp(0.5,0.5));
    mIconSpr->setScale(1.2);
    mBatchNode->addChild(mIconSpr);
    return true;
}
コード例 #19
0
void Scene_GameItem::setItemByTag(int btnTag)
{
    CCString str;
        UIButton* itemBtn = dynamic_cast<UIButton*>(ul->getWidgetByName(str.getCString()));
    if (itemBtn) {
        itemBtn->setTextures("./CocoStudioResources/ItemSelected.png", "./CocoStudioResources/ItemSelected.png", "");
    }
    for (int i=0; i<4; i++) {
        str.initWithFormat("ItemBtn%d",i+1);
        UIButton* itemBtn = dynamic_cast<UIButton*>(ul->getWidgetByName(str.getCString()));

        if (itemBtn) {
            if (btnTag == i) {
                itemBtn->setTextures("./CocoStudioResources/ItemSelected.png", "./CocoStudioResources/ItemSelected.png", "");

            }else
            {
                itemBtn->setTextures("./CocoStudioResources/ItemNoSelect.png", "./CocoStudioResources/ItemNoSelect.png", "");
            }
        }

    }
}
コード例 #20
0
CObjectBase* CObjectBase::createObject(const string& name)
{
    CObjectBase* pObject = NULL;
    CCDictionary* pDict = GAME_OJBECT_MANAGER->getObjectByName(name);
    if (!pDict)
    {
        return NULL;
    }
    
    CCString* strCateName = dynamic_cast<CCString*>(pDict->objectForKey("CateName"));
    if (NULL == strCateName)
    {
        return NULL;
    }

    pObject = OBJECT_FACTORY->createInstance(strCateName->getCString());
    
    if (pObject)
    {
        pObject->init(pDict);
    }
    return pObject;
}
コード例 #21
0
ファイル: MenuLayer.cpp プロジェクト: reinhardtken/fish-demo
void MenuLayer::createMenu()
{
    int fontSize = 32;
    CCString* fontName = CCString::create("Thonburi");
    
    CCMenuItemLabel* resume = CCMenuItemLabel::create(CCLabelTTF::create("Resume", fontName->getCString(), fontSize), this, menu_selector(MenuLayer::resume));
    
    CCMenuItemLabel* mainMenu = CCMenuItemLabel::create(CCLabelTTF::create("Main Menu", fontName->getCString(), fontSize), this, menu_selector(MenuLayer::mainMenu));
    
    CCMenuItemLabel* soundOn = CCMenuItemLabel::create(CCLabelTTF::create("Sound On", fontName->getCString(), fontSize));
    CCMenuItemLabel* soundOff = CCMenuItemLabel::create(CCLabelTTF::create("Sound Off", fontName->getCString(), fontSize));
    _sound = CCMenuItemToggle::createWithTarget(this, menu_selector(MenuLayer::sound), soundOff, soundOn, NULL);
    
    CCMenuItemLabel* musicOn = CCMenuItemLabel::create(CCLabelTTF::create("Music On", fontName->getCString(), fontSize));
    CCMenuItemLabel* musicOff = CCMenuItemLabel::create(CCLabelTTF::create("Music Off", fontName->getCString(), fontSize));
    _music = CCMenuItemToggle::createWithTarget(this, menu_selector(MenuLayer::music), musicOff, musicOn, NULL);
    
    CCMenuItemLabel* reset = CCMenuItemLabel::create(CCLabelTTF::create("Reset", fontName->getCString(), fontSize), this, menu_selector(MenuLayer::reset));
    
    CCMenu* menu = CCMenu::create(resume, mainMenu, _sound, _music, reset, NULL);
    menu->alignItemsVerticallyWithPadding(10);
    this->addChild(menu);
}
コード例 #22
0
ファイル: World.cpp プロジェクト: DustinJia/Alliance-Warfare
void World::showLevel()
{
    /*添加显示板*/
    CCSprite* sprite = CCSprite::create("displayLevel.png");
    addChild(sprite);
    CCLabelBMFont* label = CCLabelBMFont::create("Level", "testChinese.fnt");
    sprite->addChild(label);
    
    CCString* string;
    if (CCUserDefault::sharedUserDefault()->getBoolForKey("ifEndlessMode")) {
        string = CCString::createWithFormat("Level %d", Interface::sharedInterface()->level);
    }
    else {
        string = CCString::createWithFormat("Level %d", Interface::sharedInterface()->level1);
    }
    
    label->setString(string->getCString());
    label->setPosition(ccp(sprite->boundingBox().size.width * 0.5, sprite->boundingBox().size.height * 0.5));
    
    sprite->setPosition(ccp(size.width * 0.5, size.height - sprite->boundingBox().size.height * 0.3));
    sprite->setScale(0.5);
    sprite->setTag(tag_sprite);
}
コード例 #23
0
void ResourceManager::updateVersion()
{
    if (this->isDevelopMode()) {
        return;
    }
    if (localVersion < serverResourceVersion) {
        //(1) 下载地址
        std::string downloadPath = FileManager::splicePath(this->rootUrl, RMServerUpdateDirectory);
        CCString* versionPath = CCString::createWithFormat(RMVersionPathFormat,serverResourceVersion,localVersion);
        downloadPath = FileManager::splicePath(downloadPath, versionPath->getCString());
        downloadPath = FileManager::splicePath(downloadPath, RMUpdateZipFile);
        downloader->setUrl(downloadPath.c_str());
        //(2) 保存路径
        std::string savePath = this->fullLocalResourcePath(RMUpdateZipFile);
        downloader->setFullPath(savePath.c_str());
        //(3) 下载
        this->downloadFileType = kDownloadFileTypeUpdatePackage;
        downloader->download();
    }else{
        std::string errorMsg = LocalizedString("Resources are already up to date");
        this->reportError(errorMsg);
    }
}
コード例 #24
0
ファイル: AppDelegate.cpp プロジェクト: NatWeiss/cocos2d-x
bool AppDelegate::applicationDidFinishLaunching()
{
    // 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);

    [! if CC_USE_LUA]
    // register lua engine
    CCLuaEngine* pEngine = CCLuaEngine::defaultEngine();
    CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine);

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    CCString* pstrFileContent = CCString::createWithContentsOfFile("hello.lua");
    if (pstrFileContent)
    {
        pEngine->executeString(pstrFileContent->getCString());
    }
#else
    std::string path = CCFileUtils::sharedFileUtils()->fullPathForFilename("hello.lua");
    pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str());
    pEngine->executeScriptFile(path.c_str());
#endif
    [! else]
    // create a scene. it's an autorelease object
    CCScene *pScene = HelloWorld::scene();

    // run
    pDirector->runWithScene(pScene);
    [! endif]
    return true;
}
コード例 #25
0
void Scene_GameItem::itemBtnCallBack(cocos2d::CCObject *object)
{
    UIButton* btn = (UIButton*)object;
    UIImageView* img;
    
    //通过游戏的道具信息获取道具价钱.
    sItemData* itemData = CGameInfoMan::sharedInstance().getItemDate(GameShare_Global::shareGlobal()->gameType, btn->getTag());

    UILabel* itemInfo = dynamic_cast<UILabel*>(ul->getWidgetByName("Label_591"));
    
    
    switch (btn->getTag()) {
        case Btn_1:
            img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_1"));
            break;
        case Btn_2:
            img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_2"));
            break;
        case Btn_3:
            img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_3"));
            break;
        case Btn_4:
            img = dynamic_cast<UIImageView*>(ul->getWidgetByName("IsSelectImg_4"));
            break;
        default:
            break;
    }
    
    if (img->isVisible()) {
        
        img->setVisible(false);

        if (itemData) {
            CCString infoStr;
            infoStr.initWithFormat("%s:%s",itemData->ItemName.c_str(),itemData->ItemDetail.c_str());
            itemInfo->setText(infoStr.getCString());
            needGold -= itemData->CurrencyValue;
        }
    }else{
        img->setVisible(true);
        if (itemData) {
            CCString infoStr;
            infoStr.initWithFormat("%s:%s",itemData->ItemName.c_str(),itemData->ItemDetail.c_str());
            itemInfo->setText(infoStr.getCString());
            needGold += itemData->CurrencyValue;
            if (CPlayerInfoMan::sharedInstance().getPlayerInfo().nMoney < needGold) {
                GameLayer_Alert *alertUl = GameLayer_Alert::creatWithOnlySure(Type_OnlySure);
                needGold -= itemData->CurrencyValue;
                alertUl->setText(GET_STRING_CSV(1010000021));
                this->addChild(alertUl,1);
                img->setVisible(false);
            }
        }
        
    }
    this->setItemByTag(btn->getTag());
}
コード例 #26
0
void MoreDiamondDialog::onGetAvatarCompleted( CCNode* pSender, void *data )
{
	CCLOG("onGetAvatarCompleted");
	if (data != NULL)
	{
		CCDictionary *convertedData = (CCDictionary *)data;
		CCString* s = (CCString*)convertedData->objectForKey("isSuccess");
		if (s->boolValue())
		{
			CCLOG("CPP Get Avatar Completed: TRUE");
			DataManager::sharedDataManager()->SetFbIsLogIn(true);

			CCString* path = (CCString*)convertedData->objectForKey("path");
			DataManager::sharedDataManager()->SetFbPhotoPath(path->getCString());

			MenuScene* parent = (MenuScene*) this->getParent();
			parent->m_itFacbook->runAction(CCFadeOut::create(0.5f));

			//show
			if (m_curOperator.compare("invite") == 0)
			{
				inviteCallback(NULL);
			} 
			else if (m_curOperator.compare("share") == 0)
			{
				shareCallback(NULL);
			}
		} 
		else
		{
			CCLOG("CPP Get Avatar Completed: FALSE");
			CCMessageBox("Không thể kết nối", "Lỗi");
		}

		NDKHelper::RemoveSelector("MoreDiamondDialog", "onGetAvatarCompleted");
	}
}
コード例 #27
0
void BattleCharacter::BuildCharacter(CCDictionary* dic)
{	
	int nID = ((CCString*)dic->objectForKey("ID"))->intValue();
	int x = ((CCString*)dic->objectForKey("x"))->intValue()+SQUARE_LENTH/2;
	int y = ((CCString*)dic->objectForKey("y"))->intValue()+SQUARE_LENTH/2;
	int nForceFlag = ((CCString*)dic->objectForKey("FORCE"))->intValue();
	//初始化角色属性
	m_nCharID = nID;
	CharacterDataLoader* pData = CharacterDataLoader::instance();
	pData->GetCharacterValue(DATA_CHARACTER_STR,m_nCharID,&m_nStr);
	pData->GetCharacterValue(DATA_CHARACTER_DEF,m_nCharID,&m_nDef);
	pData->GetCharacterValue(DATA_CHARACTER_SPD,m_nCharID,&m_nSpd);
	pData->GetCharacterValue(DATA_CHARACTER_HP,m_nCharID,&m_nMaxHP);
	pData->GetCharacterValue(DATA_CHARACTER_SP,m_nCharID,&m_nMaxSP);
	m_nSP = m_nMaxSP;
	m_nHP = m_nMaxHP;
	pData->GetCharacterValue(DATA_CHARACTER_MAG,m_nCharID,&m_nMag);
	pData->GetCharacterValue(DATA_CHARACTER_DEX,m_nCharID,&m_nDex);
	pData->GetCharacterValue(DATA_CHARACTER_LUK,m_nCharID,&m_nLuk);
	pData->GetCharacterValue(DATA_CHARACTER_MOVE,m_nCharID,&m_nMove);
	pData->GetCharacterValue(DATA_CHARACTER_MINRANGE,m_nCharID,&m_nMinAtkRange);
	pData->GetCharacterValue(DATA_CHARACTER_MAXRANGE,m_nCharID,&m_nMaxAtkRange);
	m_nForceFlag = nForceFlag;
	CCString* pLevel = (CCString*)dic->objectForKey("Level");
	if (pLevel!=NULL)
	{
		int nLevel  = pLevel->intValue();
		LevelUp(nLevel-1);
		RecoverSPToMax();
		RecoverHPToMax();
	}	
	//初始化角色技能、能力
	pData->GetLevelSkills(m_nCharID,m_nLevel,m_vSkills);
	pData->GetLevelAbilities(m_nCharID,m_nLevel,m_vAbilities);
	//初始化角色状态
	InitSpritesAndStatus(x,y);
}
コード例 #28
0
ファイル: GameObject.cpp プロジェクト: lkeplei/QeeQoo
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;
}
コード例 #29
0
void EziFacebookFriend::saveData(const char* data, const char* key)
{
    if (strcmp(key, "id") == 0)
    {
        this->setID(data);
    }
    else if (strcmp(key, "name") == 0)
    {
        this->setName(data);
    }
    else if (strcmp(key, "score") == 0)
    {
        CCString* scoreString = CCString::create(data);
        _facebookScore = scoreString->intValue();
        
        //_facebookScore = std::atol(data.c_str());
    }
    else if (strcmp(key, "picURL") == 0)
    {
        this->setPhotoURL(data);
    }
    else if (strcmp(key, "installed") == 0)
    {
        if (strcmp(data, "1") == 0)
        {
            _installed = true;
        }
        else
        {
            _installed = false;
        }
    }
    else
    {
        CCLOG("Invalid Key %s", key);
    }
}
コード例 #30
0
ファイル: GameScene.cpp プロジェクト: shinriyo/expeller
// 赤をタップした?
void Game::attackBlock(CCPoint point)
{
    CCPoint tileCoord = this->tileCoordForPosition(point);;
    
    int tileGid = _meta->tileGIDAt(tileCoord);
    if (tileGid) {
        CCDictionary *properties = _tileMap->propertiesForGID(tileGid);
        if (properties) {
            // obstacle
            CCString *collision = new CCString();
            *collision = *properties->valueForKey("Collidable");
            
            // Moveable
            //CCString *move = new CCString();
            //*move = *properties->valueForKey("Moveable");
            // Breakable
            CCString *breakable = new CCString();
            *breakable = *properties->valueForKey("Breakable");

            // 殴れる判定
            if (breakable && breakable->compare("True") == 0) {
            //if (collision && (collision->compare("True") == 0)) {
                CCLog("Attackable");
                // TODO:
                
                // ブロック消す
                //_meta->removeTileAt(tileCoord);
                //_foreground->removeTileAt(tileCoord);
                /*CCSprite *sprite = _background->tileAt(tileCoord);
                if(sprite->getTag() == TAPPABLE)
                {
                    CCLog("OKsssss");
                }*/
            }
        }
    }
}