Exemplo n.º 1
0
void BossLottery::btnHandler()
{
    int cost = INSTANCE(SystemConfigRule)->getBossLotteryCost();
    if(times > 1){
        if(cost >= INSTANCE(UserData)->getCurrentMoney()){
            INSTANCE(MessageBoxFacade)->showMessageBox("元宝不足,是否充值?", INSTANCE(RechargeFacade), callfunc_selector(RechargeFacade::open),"充值");
            return;
        }
        INSTANCE(UserData)->costCurrentMoney(cost);
        INSTANCE(MoneyLayerManager)->createReduceMoney(cost);
    }
    
    CCNotificationCenter::sharedNotificationCenter()->postNotification(NoticeUpdateMoney);
    btn->setEnabled(false);
    closeBtn->setEnabled(false);
    int r = INSTANCE(SystemConfigRule)->getWheelMultiple();
    result = getMultiple(r);
    INSTANCE(BossLotteryFacade)->setBossMultiple(result);
    CCRotateBy *rotate = CCRotateBy::create(4.0f, 3600 + r * 60 - 30);
    CCEaseInOut *easeInOut = CCEaseInOut::create((CCActionInterval *)rotate->copy()->autorelease(), 1.5f);
    
    CCSequence *action = CCSequence::create(easeInOut,CCCallFunc::create(this, callfunc_selector(BossLottery::rotateComplete)),NULL);
    
    circle->setRotation(0);
    circle->runAction(action);
    
    costLabel->setString(CCString::createWithFormat("消耗%d元宝",cost)->getCString());
    INSTANCE(UserData)->addWheelTimes(1);
    
    times++;
}
Exemplo n.º 2
0
//------------------------------------------------------------------
//
// Test5
//
//------------------------------------------------------------------
Test5::Test5()
{
	CCSprite* sp1 = CCSprite::spriteWithFile(s_pPathSister1);
	CCSprite* sp2 = CCSprite::spriteWithFile(s_pPathSister2);
	
	sp1->setPosition(CCPointMake(100,160));
	sp2->setPosition(CCPointMake(380,160));

	CCRotateBy* rot = CCRotateBy::actionWithDuration(2, 360);
	CCActionInterval* rot_back = rot->reverse();
	CCAction* forever = CCRepeatForever::actionWithAction(
													(CCActionInterval*)(CCSequence::actions(rot, rot_back, NULL)) 
												);
	CCAction* forever2 = (CCAction*)(forever->copy()->autorelease());
	forever->setTag(101);
	forever2->setTag(102);
												  
	addChild(sp1, 0, kTagSprite1);
	addChild(sp2, 0, kTagSprite2);
			
	sp1->runAction(forever);
	sp2->runAction(forever2);
	
	schedule( schedule_selector(Test5::addAndRemove), 2.0f);
}
//
// RotateBy
//
CCRotateBy* CCRotateBy::actionWithDuration(ccTime duration, float fDeltaAngle)
{
	CCRotateBy *pRotateBy = new CCRotateBy();
	pRotateBy->initWithDuration(duration, fDeltaAngle);
	pRotateBy->autorelease();

	return pRotateBy;
}
Exemplo n.º 4
0
CCRotateBy* CCRotateBy::create(float fDuration, float fDeltaAngleX, float fDeltaAngleY)
{
    CCRotateBy *pRotateBy = new CCRotateBy();
    pRotateBy->initWithDuration(fDuration, fDeltaAngleX, fDeltaAngleY);
    pRotateBy->autorelease();
    
    return pRotateBy;
}
Exemplo n.º 5
0
CCAction *SudokuActionManager::createFailInputCellAction(CCPoint pt){
    
    CCMoveBy *acMove = CCMoveBy::create(0.2,pt);
    CCRotateBy *rotate = CCRotateBy::create(0.2,80.f);
    CCJumpBy *jump = CCJumpBy::create(0.5,ccp(0,0),25,5);
    CCSequence *inputCellAction = CCSequence::create(acMove,rotate, rotate->reverse(), acMove->reverse(), jump, NULL);
    
    return inputCellAction;
}
Exemplo n.º 6
0
////////////////////////////////////////////////////////
//
// For test functions
//
////////////////////////////////////////////////////////
void performanceActions(CCSprite* pSprite)
{
    CCSize size = CCDirector::sharedDirector()->getWinSize();
    pSprite->setPosition(ccp((rand() % (int)size.width), (rand() % (int)size.height)));

    float period = 0.5f + (rand() % 1000) / 500.0f;
    CCRotateBy* rot = CCRotateBy::create(period, 360.0f * CCRANDOM_0_1());
    CCActionInterval* rot_back = rot->reverse();
    CCAction *permanentRotation = CCRepeatForever::create((CCActionInterval *)CCSequence::create(rot, rot_back, NULL));
    pSprite->runAction(permanentRotation);

    float growDuration = 0.5f + (rand() % 1000) / 500.0f;
    CCActionInterval *grow = CCScaleBy::create(growDuration, 0.5f, 0.5f);
    CCAction *permanentScaleLoop = CCRepeatForever::create((CCActionInterval *)CCSequence::create(grow, grow->reverse()));
    pSprite->runAction(permanentScaleLoop);
}
Exemplo n.º 7
0
void HelloWorld::ccTouchEnded(cocos2d::CCTouch *pTouches, cocos2d::CCEvent *pEvent){
	if(m_score<0){
		return;
	}
	CCPoint  point = pTouches->getLocation();
	char pos[100];

	int y_ = (int)((point.y-diamondRect.origin.y)/dh);
	int y = 7-y_;
	int x  = (int)((point.x-diamondRect.origin.x)/dw);
	int result[64] = {0};
	if(y>=8||x>=8){
		return;
	}
	int count = handlerTouchInSquare(y*8+x, result);
	if(count < 3)
		return;

	for(int i = 0; i < count; i++){
		CCSprite *sprite = diamonds[result[i]];
		CCRotateBy *rotateAct = new CCRotateBy();
		rotateAct->initWithDuration(0.2f, 90.0f);
		sprite->runAction(rotateAct);
		
		char str[20];
		CCImage *image = new CCImage();
		
		int color = getDiamond(str);
		base[result[i]] = color;
		image->initWithImageFile(str, CCImage::kFmtJpg);

		CCTexture2D* texture = new CCTexture2D();
		texture->initWithImage(image);
		sprite->setTexture(texture);
	}
	//delete rotateAct;
	m_score += 5*count;
	char str[20];
	sprintf(str, "Score: %d", m_score);
	pLabelScore->setString(str);
	//fflush(file);
}
CCObject* CCRotateBy::copyWithZone(CCZone *pZone)
{
	CCZone* pNewZone = NULL;
	CCRotateBy* pCopy = NULL;
	if(pZone && pZone->m_pCopyObject) 
	{
		//in case of being called at sub class
		pCopy = (CCRotateBy*)(pZone->m_pCopyObject);
	}
	else
	{
		pCopy = new CCRotateBy();
		pZone = pNewZone = new CCZone(pCopy);
	}

	CCActionInterval::copyWithZone(pZone);

	pCopy->initWithDuration(m_fDuration, m_fAngle);

	CC_SAFE_DELETE(pNewZone);
	return pCopy;
}
Exemplo n.º 9
0
bool FlySystemUpdateHint::init()
{
    CCSafeNotificationCenter::sharedNotificationCenter()->postNotification("remove_hint");
    
    CCBLoadFile("FlySystemUpdateHint", this, this);
//    auto layer = SceneController::getInstance()->getCurrentLayerByLevel(LEVEL_TIP);
//    layer->addChild(this,1000);
//    auto size = CCDirector::sharedDirector()->getWinSize();
//    this->setPosition(ccp(size.width / 2, size.height-210));
    
//    this->setPosition(ccp(230, 185));
//    this->setPosition(ccp(size.width / 2, 185));
    if(m_type == FLY_HINT_SHAKEALLIANCE){
        m_shakeSp->setVisible(true);
        CCRotateBy * roaction = CCRotateBy::create(0.1f,60);
        CCRepeat * r1 = CCRepeat::create(CCSequence::create(roaction,roaction->reverse(),nullptr),4);
        CCDelayTime * d = CCDelayTime::create(1.0f);
        m_shakeSp->runAction(CCRepeatForever::create(CCSequence::create(r1,d,nullptr)));
    }else{
        m_shakeSp->setVisible(false);
    }
    double curTime = GlobalData::shared()->getWorldTime();
    m_countDown = GlobalData::shared()->changeTime(m_countDown/1000);
    m_time = (long)floor( m_countDown - curTime );
    
    string delayTime = CC_ITOA(m_time/60);
    //delayTime.append("m");

    if(m_type==FLY_HINT_KING && m_icon==""){
        string temp = "";
        int num = 2;
        for (int i=0; i<num; i++) {
            temp.append(m_tip);
            if(i!=1){
                temp.append("          ");
            }
        }
        m_tip = temp;
    }
    m_rollText = FlyRollingText::create(m_tip.c_str(), 320, 24, ccc3(245,233,215), 60, 1,m_icon);
    m_rollTime = m_rollText->getRollingTime();
    this->setScaleY(0);
    

    
    one = CCSequence::create(CCCallFunc::create(this, callfunc_selector(FlySystemUpdateHint::showUIQuestNode))
                             ,CCScaleTo::create(0.2, 1, 1)
                             , CCCallFunc::create(this, callfunc_selector(FlySystemUpdateHint::rollText))
                             , CCDelayTime::create(m_rollTime)
                             , CCScaleTo::create(0.4, 1, 0)
                             , CCCallFunc::create(this, callfunc_selector(FlySystemUpdateHint::hideUIQuestNode))
                             , NULL
                             );
    if (CCCommonUtils::isIosAndroidPad() && CCCommonUtils::getIsHDViewPort())
    {
        one = CCSequence::create(CCCallFunc::create(this, callfunc_selector(FlySystemUpdateHint::showUIQuestNode))
                                 ,CCScaleTo::create(0.2, 2, 2)
                                 , CCCallFunc::create(this, callfunc_selector(FlySystemUpdateHint::rollText))
                                 , CCDelayTime::create(m_rollTime)
                                 , CCScaleTo::create(0.4, 2, 0)
                                 , CCCallFunc::create(this, callfunc_selector(FlySystemUpdateHint::hideUIQuestNode))
                                 , NULL);
    }
    
    m_btnClose->setVisible(m_type==FLY_HINT_WAR);
    
    
    return true;
}
Exemplo n.º 10
0
bool IFShakeGuideLayer::initData()
{
    this->setVisible(false);
    m_defaultWidth = 140;
    if (CCCommonUtils::isIosAndroidPad())
    {
        m_defaultWidth = 240;
    }
    CCLoadSprite::doResourceByCommonIndex(500, true);
    setCleanFunction([](){
        CCLoadSprite::doResourceByCommonIndex(500, false);
    });
    
    CCBLoadFile("shakeGuideLayer",this,this);
    string infoStr("");
    int guideTime = CCUserDefault::sharedUserDefault()->getIntegerForKey(MSG_SHAKEGUIDETIME, 0);
    
    string shakePicStr = GlobalData::shared()->shakePicStr;
    vector<string> picVec ;
    CCCommonUtils::splitString(shakePicStr, "|", picVec);
    
    int count = picVec.size();
    int index = -1;
    if(count > 0 ){
        index = rand() % count;
    }
    if (m_forceShake) {
        string picStr = "g007.png";
        auto m_pic= CCLoadSprite::createSprite(picStr.c_str());
        CCCommonUtils::setSpriteMaxSize(m_pic, 100);
        m_head->addChild(m_pic);
    }
    if (index != -1) {
        m_headImgNode = HFHeadImgNode::create();
        m_headImgNode->initHeadImgUrl2(m_head, CCCommonUtils::getShakePicUrl(picVec[index]), 1.0f, 100, true);
        CCLOG("shakelog: picUrl%s",CCCommonUtils::getShakePicUrl(picVec[index]).c_str());
    }
    schedule(schedule_selector(IFShakeGuideLayer::monitorPic), 0.5);
    
    m_startTime  = WorldController::getInstance()->getTime()/1000;
    if (guideTime == 0) {
        infoStr = _lang("113100");
    }else if (guideTime == 1){
        infoStr = _lang("113108");
    }else if (guideTime == 2){
        infoStr = _lang("113103");
    }else{
        int randContainerArr[] = {113100,113101,113102,113103,113108,113109};
        int randNUm = rand() % 6;
        CCLOG("shakelog: randnum  %d",randNUm);
        infoStr = _lang(CC_ITOA(randContainerArr[randNUm]));
    }
    if (m_forceShake) {
        infoStr = _lang("113103");
    }
    m_hintText->setString(infoStr.c_str());
    
    CCUserDefault::sharedUserDefault()->setIntegerForKey(MSG_SHAKEGUIDETIME, ++guideTime);

    m_shakeSp->stopAllActions();
    
    CCRotateBy * roaction = CCRotateBy::create(0.1f,60);
    CCRepeat * r1 = CCRepeat::create(CCSequence::create(roaction,roaction->reverse(),nullptr),4);
    CCDelayTime * d = CCDelayTime::create(2.0f);
    m_shakeSp->runAction(CCRepeatForever::create(CCSequence::create(r1,d,nullptr)));
    
    m_bgNode->setVisible(false);
    m_bgNode->retain();
    m_bgNode->removeFromParent();
    m_clipNode = CCClipNode::create(modelWidth, 150);
    if (CCCommonUtils::isIosAndroidPad())
    {
        m_clipNode = CCClipNode::create(modelWidth, 320);
    }
    m_clipNode->setAnchorPoint(ccp(0, 0));
    m_clipNode->addChild(m_bgNode);
    m_bgNode->release();
    this->addChild(m_clipNode);
//    auto btnPic1 = CCLoadSprite::createScale9Sprite("Mail_btn03.png");
//    if(btnPic1){
//        btnPic1->setScale(0.8);
//        m_btnNode->addChild(btnPic1);
//    }
    return true;
}