void GameUI_MainTitle::fb_Callback_Login(bool ret)
{
    if(ret == true)
    {
        CCArray* friList = Facebook_Manager::sharedInstance()->getFriendList();
        for(int i=0; i<friList->count(); ++i)
        {
            Facebook_Account* fri = (Facebook_Account*)friList->objectAtIndex(i);
            Facebook_Manager::sharedInstance()->GetPicture(fri->fbID, this);
        }
    }
    else
    {
        
    }
}
Exemple #2
0
void MainScene::makeAFocusOfListForMotion()
{
    CCArray* items = motionlist->getItems();
    for (int i = 0; i < items->count(); i++) {
        Layout * bg = (Layout*)items->objectAtIndex(i);
        
        if (i == xSkill->getCurAtkIndex()) {
            bg->setBackGroundColorType(LAYOUT_COLOR_SOLID);
            bg->setBackGroundColor(ccBLACK);
        }
        else
        {
            bg->setBackGroundColorType(LAYOUT_COLOR_NONE);
        }
    }
}
Exemple #3
0
void Map::disposeNodes()
{
	int n = nodes->count();
	int m;
	for (int i = 0; i < n; i ++)
	{
		CCArray* colList = (CCArray*) nodes->objectAtIndex(i);
		m = colList->count();
		for (int j = 0; j < n; j++)
		{
			delete colList->objectAtIndex(j);
		}
		delete colList;
	}
	delete nodes;
}
//------------------------------------------------------------------------------
CCArray*    LHLayer::allLayers(void){
#if COCOS2D_VERSION >= 0x00020000
    CCArray* array = CCArray::create();
#else
    CCArray* array = CCArray::array();
#endif
    
    CCArray* children = getChildren();
    for(int i = 0; i < children->count(); ++i){
        CCNode* node = (CCNode*)children->objectAtIndex(i);
        if(LHLayer::isLHLayer(node)){
            array->addObject(node);
        }
    }
    return array;
}
void reorderZindex()
{
    GraphicLayer* layer = GraphicLayer::sharedLayer();
    CCArray* children = layer->getChildren();
    if(children != NULL)
    {
        for(int i = 0 ; i < children->count(); i++)
        {
            RawObject* child = (RawObject*)children->objectAtIndex(i);
            if(child->getZOrder() != 0)
            {
                layer->reorderChild(child, child->getZOrder());
            }
        }
    }
}
//------------------------------------------------------------------------------
LHBezier*   LHLayer::bezierWithUniqueName(const std::string& name){
    CCArray* children = getChildren();
    for(int i = 0; i < children->count(); ++i){
        CCNode* node = (CCNode*)children->objectAtIndex(i);
        if(LHBezier::isLHBezier(node)){
            if(((LHBezier*)node)->getUniqueName() == name)
                return (LHBezier*)node;
        }
        else if(LHLayer::isLHLayer(node)){
            LHBezier* child = ((LHLayer*)node)->bezierWithUniqueName(name);
            if(child)
                return child;
        }
    }
    return NULL;    
}
Exemple #7
0
//初始化矩阵数据
void RootEngine::initStars()
{
    dataSource = CCArray::create();
    blocksInSameColor = CCArray::create();
    checkedBlocks = CCArray::create();
    allNodes = CCArray::create();
    allNodes->retain();
    dataSource->retain();
    blocksInSameColor->retain();
    checkedBlocks->retain();
    
    Size contentSize = containerView->getContentSize();
    perWidth = contentSize.width/lineCount;
    perHeight = perWidth;
    
    CCArray* nameArray = CCArray::create();
    for (int i = 0; i<typeCount; i++) {
        __String* s = __String::createWithFormat("img_star_%02d.png",i);
        nameArray->addObject(s);
    }
    
    for (int i = 0; i<lineCount; i++) {
        CCArray* lineArray = CCArray::create();
        dataSource->addObject(lineArray);
        for (int j = 0; j<rowCount; j++) {
            int type = arc4random()%typeCount;
            StarModel* model = new StarModel();
            model->type = type;
            model->line = i;
            model->row = j;
            lineArray->addObject(model);
            
            __String* file = (__String*)nameArray->objectAtIndex(model->type);
            Sprite* bSprite = Sprite::create(file->getCString());
            bSprite->setPosition(Point((i+ 0.5)*this->perHeight, (j+0.5)*this->perWidth));
            bSprite->setScale(CommonUtil::getScaleForTargetWithImage(perWidth, bSprite));
            containerView->addChild(bSprite);
            
            StarNode* node = new StarNode();
            node->sprite = bSprite;
            node->model = model;
            node->targetCenter = bSprite->getPosition();
            model->node = node;
            allNodes->addObject(node);
        }
    }
}
Exemple #8
0
void GameBoard::checkDeleteBubbles(Bubble * bubble){
    CCArray * neighbors = getNeighbors(bubble);
    neighbors->retain();
    Bubble * tempBubble;
    bool hasChecked = false;
    CCPoint *point;
    CCPoint *checkedPoint;
    for(int i = 0; i < neighbors->count(); i++){
        point = (CCPoint *) neighbors->objectAtIndex(i);
        //CCLOG("P:%i", (int) point->y);
        //CCLOG("PP:%i", (int) point->x);
        tempBubble = getBubble(point->y, point->x);
        if (tempBubble == NULL) {
            continue;
        }
        tempBubble->retain();
        
        for (int j = 0; j < bubblesChecked->count(); j++) {
            checkedPoint = (CCPoint *) bubblesChecked->objectAtIndex(j);
            //            CCLOG("XX:%i", (int) checkedPoint->x);
            //            CCLOG("YX:%i", (int) checkedPoint->y);
            //            CCLOG("XXX:%i", (int) tempBubble->col);
            //            CCLOG("YXX:%i", (int) tempBubble->row);
            if (checkedPoint->x == tempBubble->col && checkedPoint->y == tempBubble->row) {
                hasChecked = true;
                break;
            }
        }
        
        if (hasChecked) {
            hasChecked = false;
            continue;
        }else{
            bubblesChecked->addObject(point);
        }
        
        //        CCLOG("ID:%i", (int) tempBubble->bubbleID);
        //        CCLOG("X:%i", (int) point->x);
        //        CCLOG("Y:%i", (int) point->y);
        
        if(bubble->bubbleID == tempBubble->bubbleID){
            bubblesDeleted->addObject(point);
            checkDeleteBubbles(tempBubble);
        }
    }
    return ;
}
UIAction* UIActionManager::GetActionByName(const char* jsonName,const char* actionName)
{
    CCArray* actionList = (CCArray*)(m_pActionDic->objectForKey(jsonName));
    if (!actionList)
    {
        return NULL;
    }
    for (int i=0; i<actionList->count(); i++)
    {
        UIAction* action = dynamic_cast<UIAction*>(actionList->objectAtIndex(i));
        if (strcmp(actionName, action->getName()) == 0)
        {
            return action;
        }
    }
    return NULL;
}
Exemple #10
0
Image* Scene::getButtonAtPosition(Vec2 position, bool state)
{
    Image* target = NULL;
    CCArray* objects = GraphicLayer::sharedLayer()->allVisibleObjectsAtPosition(position);
    for(int i = 0; i < objects->count() && target == NULL; i++)
    {
        RawObject* obj = (RawObject*)objects->objectAtIndex(i);
        if(obj->isVisible() && obj->getEventActivated() && !obj->getEventName().empty() && obj->getEventName()[0] != '\0' && dynamic_cast<Image*>(obj) != NULL)
        {
            //If state = false, the object imagefile must finish by "-on" and and have an _OriginalImageFile
            char *end = strrchr(((Image*)obj)->getImageFile().c_str(), '-');
            if(state || (end && strcmp(end, "-on") == 0 && obj->getEventInfos()->objectForKey("_OriginalImageFile") != NULL))
                target = (Image*)obj;
        }
    }
    return target;
}
Exemple #11
0
void TestColliderDetector::update(float delta)
{
    armature2->setVisible(true);

    CCRect rect = bullet->boundingBox();

    // This code is just telling how to get the vertex.
    // For a more accurate collider detection, you need to implemente yourself.
    CCDictElement *element = NULL;
    CCDictionary *dict = armature2->getBoneDic();
    CCDICT_FOREACH(dict, element)
    {
        CCBone *bone = static_cast<CCBone*>(element->getObject());
        CCArray *bodyList = bone->getColliderBodyList();

        CCObject *object = NULL;
        CCARRAY_FOREACH(bodyList, object)
        {
            ColliderBody *body = static_cast<ColliderBody*>(object);
            CCArray *vertexList = body->getCalculatedVertexList();

            float minx, miny, maxx, maxy = 0;
            int length = vertexList->count();
            for (int i = 0; i<length; i++)
            {
                CCContourVertex2 *vertex = static_cast<CCContourVertex2*>(vertexList->objectAtIndex(i));
                if (i == 0)
                {
                  minx = maxx = vertex->x;
                  miny = maxy = vertex->y;
                }
                else
                {
                    minx = vertex->x < minx ? vertex->x : minx;
                    miny = vertex->y < miny ? vertex->y : miny;
                    maxx = vertex->x > maxx ? vertex->x : maxx;
                    maxy = vertex->y > maxy ? vertex->y : maxy;
                }
            }
            CCRect temp = CCRectMake(minx, miny, maxx - minx, maxy - miny);

            if (temp.intersectsRect(rect))
            {
                armature2->setVisible(false);
            }
        }
Exemple #12
0
int CCLuaEngine::executeNodeEvent(CCNode* pNode, int nAction)
{
    CCLuaValueDict event;
    switch (nAction)
    {
        case kCCNodeOnEnter:
            event["name"] = CCLuaValue::stringValue("enter");
            break;

        case kCCNodeOnExit:
            event["name"] = CCLuaValue::stringValue("exit");
            break;

        case kCCNodeOnEnterTransitionDidFinish:
            event["name"] = CCLuaValue::stringValue("enterTransitionFinish");
            break;

        case kCCNodeOnExitTransitionDidStart:
            event["name"] = CCLuaValue::stringValue("exitTransitionStart");
            break;

        case kCCNodeOnCleanup:
            event["name"] = CCLuaValue::stringValue("cleanup");
            break;

        default:
            return 0;
    }

    m_stack->clean();
    m_stack->pushCCLuaValueDict(event);

    CCArray *listeners = pNode->getAllScriptEventListeners();
    CCScriptHandlePair *p;
    for (int i = listeners->count() - 1; i >= 0; --i)
    {
        p = dynamic_cast<CCScriptHandlePair*>(listeners->objectAtIndex(i));
        if (p->event != NODE_EVENT || p->removed) continue;
        m_stack->copyValue(1);
        m_stack->executeFunctionByHandler(p->listener, 1);
        m_stack->settop(1);
    }

    m_stack->clean();
    return 0;
}
void XTLayer::ccTouchesMoved(cocos2d::CCSet* _touches, cocos2d::CCEvent* event)
{
    this->_touchHasMoved = true;
    CCArray *allTouches = xtAllTouchextromSet(_touches);
    
    CCTouch* fingerOne = (CCTouch *)allTouches->objectAtIndex(0);
    CCPoint pointOne = CCDirector::sharedDirector()->convertToUI(fingerOne->getLocationInView());
    
    CCPoint location = this->convertToNodeSpace(pointOne);
    this->xtActualPoint = location;
    
    CCLog("Position:%f,%f",location.x,location.y);
    // Passthrough
    this->xtTouchesMoved(location);
    this->xtTouchesMoved(_touches, event);

}
Exemple #14
0
/*
 * シングルトンインスタンスを取得。
 */
EvoMstList* EvoMstList::shared()
{
	if( EvoMstListInstance == NULL )
	{
		EvoMstListInstance= new EvoMstList();
        
        //读取sqlite
        CCArray * list = SQLiteManager::sharedInstance()->selectRows("select * from Evolution");
        for (int i=0; i<list->count(); i++) {
            EvoMst * EvoMst = new class EvoMst();
            EvoMst->initWithArray(dynamic_cast<CCDictionary*>(list->objectAtIndex(i)));
            EvoMstListInstance->addObject(EvoMst);
        }
	}

	return EvoMstListInstance;
}
Exemple #15
0
/*
 * シングルトンインスタンスを取得。
 */
PurchaseMstList* PurchaseMstList::shared()
{
	if( PurchaseMstListInstance == NULL )
	{
		PurchaseMstListInstance= new PurchaseMstList();
        
        //读取sqlite
        CCArray * list = SQLiteManager::sharedInstance()->selectRows("select * from purchase_mst");
        for (int i=0; i<list->count(); i++) {
            PurchaseMst * PurchaseMst = new class PurchaseMst();
            PurchaseMst->initWithArray(dynamic_cast<CCDictionary*>(list->objectAtIndex(i)));
            PurchaseMstListInstance->addObject(PurchaseMst);
        }
	}

	return PurchaseMstListInstance;
}
Exemple #16
0
/**
*   键盘将要出现的时候
*/
void LoginView::keyboardWillShow(CCIMEKeyboardNotificationInfo& info)
{
    CCLog("LoginView:keyboardWillShowAt(origin:%f,%f, size:%f,%f)",
        info.end.origin.x, info.end.origin.y, info.end.size.width, info.end.size.height);

    if (! this->mTrackNodeArray)
    {
        return;
    }

    CCNode* trackNode = NULL ;
    CCRect rectTracked ;
    for(int i=0; i<this->mTrackNodeArray->count(); i++) 
    {
        trackNode = (CCNode*) this->mTrackNodeArray->objectAtIndex(i) ;

        rectTracked = getRect(trackNode);
        CCLog("LoginView:trackingNodeAt(origin:%f,%f, size:%f,%f)",
            rectTracked.origin.x, rectTracked.origin.y, rectTracked.size.width, rectTracked.size.height);

        // if the keyboard area doesn't intersect with the tracking node area, nothing need to do.
        if (! CCRect::CCRectIntersectsRect(rectTracked, info.end))
        {
            continue ;
        }

        // assume keyboard at the bottom of screen, calculate the vertical adjustment.
        float adjustVert = info.end.getMaxY() - rectTracked.getMinY();
        CCLog("LoginView:needAdjustVerticalPosition(%f)", adjustVert);

        // move all the children node of KeyboardNotificationLayer
        CCArray* children = getChildren();
        CCNode* node = 0;
        int count = children->count();
        CCPoint pos;
        for (int i = 0; i < count; ++i)
        {
            node = (CCNode*)children->objectAtIndex(i);
            pos = node->getPosition();
            pos.y += adjustVert;
            node->setPosition(pos);
        }
    }

    
}
void HelloWorld::tick(float dt) {


    //=================================
    CCPoint backgroundScrollVert = ccp(-2000, 0);
    pBackgroundNode->setPosition(ccpAdd(pBackgroundNode->getPosition(), ccpMult(backgroundScrollVert, dt)));

    CCArray *BackGrounds = CCArray::createWithCapacity(2);
    BackGrounds->addObject(pSprite);
    BackGrounds->addObject(pNextSprite);
    for ( int ii = 0; ii < BackGrounds->count(); ii++ ) {
        CCSprite * BackGround = (CCSprite *)(BackGrounds->objectAtIndex(ii));
        float xPosition = pBackgroundNode->convertToWorldSpace(BackGround->getPosition()).x;
        float size = BackGround->getContentSize().width;
        if ( xPosition < -size/2 ) {
            pBackgroundNode->incrementOffset(ccp(BackGround->getContentSize().width*2,0),BackGround);
        }
    }


    //===================================

    pworld->Step(dt, 10, 10);
    for(b2Body *b = pworld->GetBodyList(); b; b=b->GetNext()) {
        if (b->GetUserData() != NULL) {

            if(b->GetType() == b2_dynamicBody)
            {
                CCSprite *ballData = (CCSprite *)b->GetUserData();
                ballData->setPosition(ccp(b->GetPosition().x * PTM_RATIO,
                                          b->GetPosition().y * PTM_RATIO));
                ballData->setRotation (-1 * CC_RADIANS_TO_DEGREES(b->GetAngle()));
            }

            /*else if(b->GetType() == b2_staticBody)
            {
            	CCSprite *ballData = (CCSprite *)b->GetUserData();
            	ballData->setPosition(ccp(b->GetPosition().x * PTM_RATIO,
            		b->GetPosition().y * PTM_RATIO));
            	ballData->setRotation (-1 * CC_RADIANS_TO_DEGREES(b->GetAngle()));
            }*/
        }
    }

}
Exemple #18
0
void PushCommonNotice::handleResponse(CCDictionary *dict)
{
    if (!dict)
        return;
    cocos2d::CCDictionary *params=_dict(dict->objectForKey("params"));
    if (!params) return;
    string msgId = params->valueForKey("msgId")->getCString();
    CCArray* array = dynamic_cast<CCArray*>(params->objectForKey("para"));
    string tip = _lang(msgId);
    if (array && array->count()>0) {
        int num = array->count();
        CCString* temp = NULL;
        std::vector<string> vArr(num,"");
        for (int i=0; i<num; i++) {
            temp = dynamic_cast<CCString*>(array->objectAtIndex(i));
            if (temp) {
                vArr[i] = temp->getCString();
            }
        }
        switch (num) {
            case 1:
                tip = _lang_1(msgId,vArr[0].c_str());
                break;
            case 2:
                tip = _lang_2(msgId,vArr[0].c_str(),vArr[1].c_str());
                break;
            case 3:
                tip = _lang_3(msgId,vArr[0].c_str(),vArr[1].c_str(),vArr[2].c_str());
                break;
            case 4:
                tip = _lang_4(msgId,vArr[0].c_str(),vArr[1].c_str(),vArr[2].c_str(),vArr[3].c_str());
                break;
            case 5:
                tip = _lang_5(msgId,vArr[0].c_str(),vArr[1].c_str(),vArr[2].c_str(),vArr[3].c_str(),vArr[4].c_str());
                break;
        }
    }
    if (tip!="") {
        double worldTime = GlobalData::shared()->getWorldTime();
        worldTime *= 1000;
        worldTime = GlobalData::shared()->renewTime(worldTime);
        auto time = worldTime+1000*60;
        CCCommonUtils::flySystemUpdateHint(time, true,tip,FLY_HINT_SYSTEM);
    }
}
void MailListTile::checkInfoOK()
{
	//m_mMenu->removeAllChildrenWithCleanup(true);
	if (m_sSystemMail.is_read)
	{
		return;
	}
	
	CCArray* menuList = m_mMenu->getChildren();
	for (unsigned int i = 0; i < menuList->count(); ++i)
	{
		CCMenuItem* pObj=(CCMenuItem*)menuList->objectAtIndex(i);
		pObj->setEnabled(false);
		pObj->setVisible(false);
	}
	m_sSystemMail.is_read = true;
	refresh();
}
Exemple #20
0
void MainScene::updateList()
{
    _listAudio->removeAllItems();
    
    for (int i = 0; i < m_vFileName.size(); ++i)
    {
        _listAudio->pushBackDefaultItem();
    }
    
    CCArray* items = _listAudio->getItems();
    for (int i = 0; i < items->count(); i++) {
        Layout * bg = (Layout*)items->objectAtIndex(i);
        bg->addTouchEventListener(this, toucheventselector(MainScene::touchEvent));
        bg->setTag(T_LIST_AUDIO);
        Label *label = (Label*)UIHelper::seekWidgetByTag(bg, 22);
        label->setText(m_vFileName.at(i));
    }
}
// Override of touches
void XTLayer::ccTouchesBegan(cocos2d::CCSet* _touches, cocos2d::CCEvent* event)
{
    this->_touchHasMoved = false;
    this->_xtTouchStart = this->millisecondNow();
    CCArray *allTouches = xtAllTouchextromSet(_touches);
    
    CCTouch* fingerOne = (CCTouch *)allTouches->objectAtIndex(0);
    CCPoint  pointOne = CCDirector::sharedDirector()->convertToUI(fingerOne->getLocationInView());
    
    CCPoint location = this->convertToNodeSpace(pointOne);
    this->xtGestureStartPoint= location;//touch locationInView:touch->view);
    this->xtPreviousPoint = location;
   
    // Passthrough
    this->xtTouchesBegan(location);
    this->xtTouchesBegan(_touches, event);

}
Exemple #22
0
void CMainCityUI::runMoveAction(int fromTag, int toTag,float moveTime)
{
	CCNode *sBtn =  m_ui->getChildByTag(fromTag);
	CButton *dBtn = dynamic_cast<CButton*>( m_ui->getChildByTag(toTag));

	CCArray *children = sBtn->getChildren();

	CCNode *child = nullptr;
	for (int i = 0; i < sBtn->getChildrenCount(); i++)
	{	
		child = (CCNode*)children->objectAtIndex(i);
		CCMoveBy *move = CCMoveBy::create(moveTime,ccp(dBtn->getPositionX() -child->getPositionX(),0));
		CCCallFuncN *hideCall = CCCallFuncN::create(this,callfuncN_selector(CMainCityUI::hideBtn));
		CCSequence *ccseque = CCSequence::create(move,hideCall,nullptr);
		child->runAction(ccseque);
	}
	m_moveX[fromTag-1] = dBtn->getPositionX() - child->getPositionX();
} 
void WordTreeScene::onSuccessComplete(const std::string& param) {
    isProcessing=true;
    
    CCDictionary* dict = CCJson::JSONObjectWithString(param.c_str());
    if( dict==NULL )
        return;
    
    CCArray* words = (CCArray*)dict->objectForKey("words");
    for( int i=0; i<words->count(); ++i ) {
        CCString* word = (CCString*)words->objectAtIndex(i);
        if( word!=NULL && word->length()>0 ) {
            CCLog("%s",word->getCString());
            WordModels::getInstance()->addWord(word->getCString());
        }
    }
    
    isProcessing = false;
}
Exemple #24
0
CCString * DataRequest::getRequestString()
{
    std::string ret = "";
    CCArray *pArray = m_pRequestDataDict->allKeys();
    for (int i = 0; i < pArray->count(); i ++)
    {
        CCString *pStr = (CCString *)pArray->objectAtIndex(i);
        CCString *pValue = (CCString *)m_pRequestDataDict->objectForKey(pStr->getCString());
        ret.append(pStr->getCString());
        ret.append("=");
        ret.append(pValue->getCString());
        if (i < pArray->count() - 1)
        {
            ret.append("&");
        }
    }
    return CCString::create(ret);
}
Exemple #25
0
void Terrain::prepareFirstHillKeyPoint(MyMap* myMap)
{
	CCTMXObjectGroup* objGroup = myMap->_map->objectGroupNamed("platform");
	CCDictionary* dict = objGroup->objectNamed("platform");
	//CCDictionary* dict = objGroup->getObjects()->obj;
	/*对象的位置**/
	int x = ((CCString*)dict->objectForKey("x"))->intValue();
	int y = ((CCString*)dict->objectForKey("y"))->intValue();
	/*刚体关键点**/
    CCArray* points = (CCArray*)dict->objectForKey("points");
    if (points && points->count() > 0) {
        CCDictionary* point = (CCDictionary*)(points->objectAtIndex(0));
        _prepareFirstHillKeyPoint = CCPointMake(
            x + ((CCString*)point->valueForKey("x"))->intValue(),
            y - ((CCString*)point->valueForKey("y"))->intValue()
        );
    }
}
Exemple #26
0
bool Lottery10TimesCommand::handleRecieve(cocos2d::CCDictionary *dict){
    if (dict->valueForKey("cmd")->compare(LOTTERY_10TIMES_COMMAND) != 0) {
        return false;
    }
    LotteryController::shared()->setSendCMD(false);
    CCDictionary* params = _dict(dict->objectForKey("params"));
    
    const CCString *pStr = params->valueForKey("errorCode");
    if (pStr->compare("")!=0)
    {
        CCCommonUtils::flyText((_lang(pStr->getCString()).c_str()));
        return false;
    }
    CCDictionary* resourceDic = _dict(params->objectForKey("resource"));
    if (resourceDic->objectForKey("chip"))
    {
        GlobalData::shared()->resourceInfo.lChip = resourceDic->valueForKey("chip")->intValue();
    }
    
    if (params->objectForKey("batchResult"))
    {
        CCArray* batchResult = dynamic_cast<CCArray*>(params->objectForKey("batchResult"));
        if(batchResult && batchResult->count()>0){
            for(int i=0;i<batchResult->count();i++){
                CCDictionary* iDict = dynamic_cast<CCDictionary*>(batchResult->objectAtIndex(i));
                if (iDict->valueForKey("type")->intValue()==1) {
                    continue;
                }
                CCDictionary* rewards = _dict(iDict->objectForKey("result"));
                CCArray* arr = CCArray::create();
                arr->addObject(rewards);
                GCMRewardController::getInstance()->retReward2(arr, false);
            }
        }
    }
    if (params->objectForKey("boxTimes"))
    {
        LotteryController::shared()->lotteryInfo.boxTimes = params->valueForKey("boxTimes")->intValue();
    }
//    LotteryController::shared()->lotteryActCmdBack(dict);
    CCSafeNotificationCenter::sharedNotificationCenter()->postNotification(LOTTERYACTVIEWCMD10, NetResult::createWithSuccess(params));
    
    return true;
}
Exemple #27
0
void CANavigationBar::showRightButton()
{
    std::vector<CAButton*>::iterator itr;
    for (itr = m_pRightButtons.begin(); itr != m_pRightButtons.end(); itr++)
    {
        (*itr)->removeFromSuperview();
    }
    m_pRightButtons.clear();
    
    CCArray* buttonItems = m_pItems.back()->getRightButtonItems();
    
    CCRect rect = this->getBounds();
    rect.size.width = rect.size.height * 0.9f;
    rect.size.height *= 0.8f;
    rect.origin.x = this->getBounds().size.width - rect.size.width * 0.7f;
    rect.origin.y = this->getBounds().size.height / 2;
    
    for (int i=0; i<buttonItems->count(); i++)
    {
        rect.origin.x -= i * rect.size.width * 1.1f;
        CAButton* button = CAButton::createWithCenter(rect, CAButtonTypeCustom);
        this->addSubview(button);
        
        CABarButtonItem* item = dynamic_cast<CABarButtonItem*>(buttonItems->objectAtIndex(i));
        if (item)
        {
            button->setTitleForState(CAControlStateNormal, item->getTitle());
            button->setTitleColorForState(CAControlStateNormal, CAColor_white);
            button->setTitleForState(CAControlStateHighlighted, item->getTitle());
            button->setTitleColorForState(CAControlStateHighlighted, ccc4(255, 255, 200, 255));
            button->setImageForState(CAControlStateNormal, item->getImage());
            if (item->getHighlightedImage())
            {
                button->setImageForState(CAControlStateHighlighted, item->getHighlightedImage());
            }
            else
            {
                button->setImageColorForState(CAControlStateHighlighted, ccc4(255, 255, 200, 255));
            }
            button->addTarget(item->getTarget(), item->getSel(), CAControlEventTouchUpInSide);
        }
        m_pRightButtons.push_back(button);
    }
}
Exemple #28
0
std::string CJLMSUtil::getJsonString(cocos2d::CCArray* v_list, std::string strKey)
{
    std::string ret = CCString::createWithFormat("{\"%s\":[", strKey.c_str())->getCString();
    std::string valueFormat = "\"[__key__]\":\"[__value__]\"";
    
    for(int arrIdx=0; arrIdx<v_list->count(); arrIdx++)
    {
        ret.append("{");
        CCDictionary *item = (CCDictionary *)v_list->objectAtIndex(arrIdx);
        CCArray* keyArray  = item->allKeys();

        for (int var = 0; var < v_list->count(); var++) {
            std::string key = ((CCString *)keyArray->objectAtIndex(var))->m_sString;
            std::string value = ((CCString *)item->valueForKey(key))->m_sString;
            std::string rowString = valueFormat;
            
            rowString = THStringUtil::replaceAll(
                                                 THStringUtil::replaceAll(
                                                                          rowString,
                                                                          "[__key__]",
                                                                          key
                                                                          ),
                                                 "[__value__]",
                                                 value
                                                 );
            
            if (var < v_list->count() - 1)
                rowString.append(",");
            ret.append(rowString);
        }
        
        if(arrIdx+1<v_list->count())
        {
            ret.append("},");
        }
        else
        {
            ret.append("}");
        }
    }
    
    ret.append("]}");
    return ret;
}
Exemple #29
0
Player* Player::spriteWithFile(const char *pszFileName, int columns, int rows)
{
//	CCSpriteFrame *frame = cacher->spriteFrameByName( pszFileName);
	CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(pszFileName);
	CCArray* aFrames = CCArray::createWithCapacity(columns * rows);


	float textureWidth =  texture->getPixelsWide();
	float textureHeight = texture->getPixelsHigh();
	float frameWidth = textureWidth / columns;
	float frameHeight = textureHeight / rows;

	for (int c = 0; c < columns; c++)
	{
		for (int r = 0; r < rows; r++)
		{
			CCSpriteFrame *frame0 = CCSpriteFrame::createWithTexture(texture, CCRectMake((c*frameWidth), (r*frameHeight), 100, 65));
			aFrames->addObject(frame0);
		}

	}

	CCAnimation *animation = CCAnimation::createWithSpriteFrames(aFrames, 0.2f);
	CCAnimate *animate = CCAnimate::create(animation);
	CCActionInterval* seq = (CCActionInterval*)(CCSequence::create( animate,   animate->copy()->autorelease(),   CCFlipX::create(false),   NULL) );

	Player *pobSprite = new Player();
	if (pobSprite && pobSprite->initWithSpriteFrame((CCSpriteFrame*) aFrames->objectAtIndex(0)))
	{
		pobSprite->scheduleUpdate();
		pobSprite->autorelease();
		pobSprite->setForwardMarch(false);
		pobSprite->setMightAsWellJump(false);
		pobSprite->setBackwardMarch(false);
		pobSprite->runAction(CCRepeatForever::create( seq ) );
	//	pobSprite->setAnimFrames( aFrames);
	//	pobSprite->setCurrentFrame(0);

		return pobSprite;
	}
	CC_SAFE_DELETE(pobSprite);
	return NULL;
}
Exemple #30
0
void YYSprite::initWithAnimation(const std::string& aniFile,const std::string& pngFileName,const std::string& path){
    const std::string aniPath = path +"/"+ aniFile + ".anu";
    ani = YYAnimation::createAnimationWithFile(aniPath);
    
    CCArray* array = split_string(pngFileName.c_str(),',');
    pngFileNameArray = new CCArray(array->count());
    for (int i = 0; i < array->count(); i++) {
        CCString * str = (CCString*)array->objectAtIndex(i);
        if (str->isEqual(new CCString(""))) {//处理空图片
            pngFileNameArray-> addObject(new CCString("null"));
        }else{
            pngFileNameArray-> addObject(new CCString(path+"/"+str->getCString()+".png"));
        }
    }
    if (ani->imageAmount != pngFileNameArray->count()) {
        CCLog("error! imageAmount: %d,get imageCount:%d",ani->imageAmount,pngFileNameArray ->count());
    }
//    setFrameByID(0,false);
}