Ejemplo n.º 1
0
void ItemTortoise::collision()
{
	// 防止持续碰撞检测
	if ( _bGodMode || _mario->_status ==Mario::DEAD ||_mario->_bGodMode)
	{
		return;
	}
	CCRect rcMario = _mario->boundingBox();
	CCRect rcItem = this->boundingBox();
	bool coll = rcMario.getMinY() > rcItem.getMaxY() - rcItem.size.height / 2;
	// mario 碰撞
	if (rcMario.intersectsRect(rcItem))
	{
		if ((_status == NORMAL))
		{
			if (marioUpHit(rcMario, rcItem, coll))
			{
				_status = SLEEP;
				scheduleOnce(schedule_selector(ItemTortoise::revive), 10.0f);
			}
			else
			{
				_mario->die(false);
			}
		}
		else if (_status == SLEEP)
		{
			Common::playMusic(std::string("CaiSiGuaiWu"));

			_speed = 150;
			_status = CRAZY;
			setGodMode(1.0f);
			unschedule(schedule_selector(ItemTortoise::revive));

			if (_mario->getPositionX() < getPositionX())
			{
				_dir = Common::RIGHT;
			}
			else
			{
				_dir = Common::LEFT;
			}

		}
		else if (_status == CRAZY)
		{
			if (marioUpHit(rcMario, rcItem, coll))
			{
				_status = DEAD;
			}
			else
			{
				_mario->die(false);
			}
		}
		else 
		{
			Common::playMusic(std::string("CaiSiGuaiWu"));

			_speed = 0;
			CCJumpBy* moveUp = CCJumpBy::create(0.7f, ccp(7, -10), 8, 1);
			CCMoveBy* moveDown = CCMoveBy::create(8.0f, ccp(0, -winSize.height));
			CCCallFunc* callfunc = CCCallFunc::create(this, callfunc_selector(ItemTortoise::die));
			CCSequence* seq = CCSequence::create(moveUp, moveDown, callfunc, NULL);

			this->runAction(seq);
		}
	}
}
Ejemplo n.º 2
0
void TanSuoLayer::refreshTime(float dt)
{
	int xunBaoCount = CS::getDiscoverLimitTimes(MyselfManager::getManager()->getMyZhuJueData()->getVipLevel());//寻宝次数上限
	m_nRefreshTime --;

	if (m_nRefreshTime <= 0)
	{
		m_nHadCount ++;
		m_nRefreshTime = 360;
		
	}
	CCLabelTTF *label = (CCLabelTTF*)mBg->getChildByTag(Tag_Label_CurNum);
	if (label)
	{
		CCString temp;
		temp.initWithFormat("%u", m_nHadCount);
		label->setString(temp.getCString());
	}
	if (m_nHadCount >= xunBaoCount)
	{
		m_nRefreshTime = 0;
		if (m_tHaixuTTF)
		{
			//m_tHaixuTTF->setPosition(ccp( mBg->getContentSize().width / 2 - 15, 44));
		}

		unschedule(SEL_SCHEDULE(&TanSuoLayer::refreshTime));
		m_tRefreshTimeTTF->setVisible(false);
		return;
	}
	

	if (m_tHaixuTTF)
	{
		//m_tHaixuTTF->setPosition(ccp( mBg->getContentSize().width / 2, 44));
	}
	if (m_tRefreshTimeTTF)
	{
		m_tRefreshTimeTTF->setVisible(true);
		m_tRefreshTimeTTF->setString(CCString::createWithFormat("(%s)",getTimeForString(m_nRefreshTime).c_str())->getCString());
	}
	/*
	m_nHadCount = data->remainder_times;
	if (xunBaoCount == data->remainder_times)
	{
		haixuNumLabel->setPosition(ccp( mBg->getContentSize().width / 2 - 15, 44));
	}
	else
	{
		int tm = (ServerTime::getTime() - data->last_modify_timestamp) % 3600;
		string timeStr = getTimeForString(tm);
		m_nRefreshTime = tm;
		CCLabelTTF *timeTTF = CCLabelTTF::create(CCString::createWithFormat("(%s)",timeStr.c_str())->getCString(), fontStr_kaiti, m_nFontSize);
		mBg->addChild(timeTTF, 1);
		//haixuNumLabel->setAnchorPoint(ccp(0,0.5));
		timeTTF->setPosition(ccp( numLabel->getPositionX() + numLabel->getContentSize().width / 2 + timeTTF->getContentSize().width / 2 + 10, numLabel->getPositionY()));
		timeTTF->setColor(ccWHITE);
		m_tRefreshTimeTTF = timeTTF;
		schedule(SEL_SCHEDULE(&TanSuoLayer::refreshTime),1.0f);
		//str = CCString::createWithFormat("()")
	}
	*/
}
Ejemplo n.º 3
0
void BulletLayer::stopShoot()//жÔØÈÎÎñÖ´ÐÐÆ÷  
{
	unschedule(schedule_selector(BulletLayer::addBullet));
}
Ejemplo n.º 4
0
void TMXIsoZorder::onExit()
{
    unschedule(schedule_selector(TMXIsoZorder::repositionSprite));
    TileDemo::onExit();
}
EquipmentUpgradeUILayer::~EquipmentUpgradeUILayer()
{
	unschedule(schedule_selector(EquipmentUpgradeUILayer::updateColdTime));
	UIManager::sharedManager()->RemoveUILayout("equipmentUpgradeLayout");
	NotificationCenter::defaultCenter()->unregisterAllMsgObserver(this);
}
Ejemplo n.º 6
0
void SGCGMovieLayer::cgSkipToBattle()
{
    unschedule(schedule_selector(SGCGMovieLayer::moveCgMsgUp));
    main::PlotPrologueStartRequest *sr = new main::PlotPrologueStartRequest();
    SGSocketClient::sharedSocketClient()->send(MSG_CGBATTLE_START, sr);
}
void SpriteMainScene::beginStat(float dt)
{
    unschedule(CC_SCHEDULE_SELECTOR(SpriteMainScene::beginStat));
    isStating = true;
}
Ejemplo n.º 8
0
void TMXIsoZorder::onExit()
{
    unschedule(CC_SCHEDULE_SELECTOR(TMXIsoZorder::repositionSprite));
    TileDemo::onExit();
}
Ejemplo n.º 9
0
    void ParticleSystem::update(fzFloat dt)
    {
        if( m_isActive && m_emissionRate ) {
            fzFloat rate = 1.0f / m_emissionRate;
            m_emitCounter += dt;
            while( m_particleCount < m_totalParticles && m_emitCounter > rate ) {
                addParticle();
                m_emitCounter -= rate;
            }
            
            m_elapsed += dt;
            if(m_duration != -1 && m_duration < m_elapsed)
                stopSystem();
        }
        
        
        m_particleIdx = 0;
        
        while( m_particleIdx < m_particleCount )
        {
            fzParticle& p = p_particles[m_particleIdx];
            
            // life
            p.timeToLive -= dt;
            
            if( p.timeToLive > 0 ) {
                
                // Mode A
                if( m_emitterMode == kFZParticleModeGravity ) {
                    
                    fzPoint tmp(p.pos);
                    if(tmp != FZPointZero)
                    {
                        // calculate tangential
                        fzPoint tangential(tmp.getPerp());
                        tangential.normalize();
                        tangential *= p.mode.A.tangentialAccel;
                        
                        // radial acceleration
                        tmp *= p.mode.A.radialAccel;

                        // radial + tangential
                        tmp += tangential;
                    }
                    
                    // (gravity + dir + radial + tangential) * dt
                    tmp += mode.A.gravity;
                    tmp += p.mode.A.dir;

                    p.pos += tmp * dt;
                }
                
                // Mode B
                else {				
                    // Update the angle and radius of the particle.
                    p.mode.B.angle += p.mode.B.degreesPerSecond * dt;
                    p.mode.B.radius += p.mode.B.deltaRadius * dt;
                    
                    p.pos.x = -fzMath_cos(p.mode.B.angle) * p.mode.B.radius;
                    p.pos.y = -fzMath_sin(p.mode.B.angle) * p.mode.B.radius;
                }
                
                // color
                p.color += p.deltaColor * dt;
                
                // size
                p.size += p.deltaSize * dt;
                p.size = p.size < 0 ? 0 : p.size;
                
                // angle
                p.rotation += p.deltaRotation * dt;
                
                
                // update values in quad
                updateQuadWithParticle(p);
                
                // update particle counter
                ++m_particleIdx;
                
            } else {
                // life < 0
                --m_particleCount;

                if( m_particleIdx != m_particleCount )
                    memmove(&p_particles[m_particleIdx], &p_particles[m_particleCount], sizeof(fzParticle));
                
                if( m_particleCount == 0 && m_autoRemoveOnFinish ) {
                    unschedule();
                    removeFromParent(true);
                    return;
                }
            }
        }
        
        if(m_particleCount)
        makeDirty(0);
        
#if FZ_VBO_STREAMING
        postStep();
#endif
    }
Ejemplo n.º 10
0
//=============================================================
//=============================================================
bool CCScrollLayer::onTouchBegan(Touch *pTouch, Event *pEvent)
{
    if (!isVisible()) // 父视图改变visible 不影响孩子的变量   //不可见依然接收touch
    { 
        return false;
    }
    
    Node* fatherNode = getParent();
    if(!fatherNode)
        return false;
    
    Point touchPointInWorld = pTouch->getLocation();
    
    Rect  selfRect = boundingBox();
    Point selfOriginInWorld = fatherNode->convertToWorldSpace(selfRect.origin);
    
    Rect selfRectInWorld = Rect(selfOriginInWorld.x,selfOriginInWorld.y,selfRect.size.width,selfRect.size.height);
    if(selfRectInWorld.containsPoint(touchPointInWorld) == false)
    {
        return false;
    }
    
    for (Node *c = this->_parent; c != NULL; c = c->getParent()) 
    {
        if (c->isVisible() == false) //若父亲有不可见的则不处理touch
        {
            return false;
        }
        
        Rect  rect = c->boundingBox();
        Node* parentNode = c->getParent();
        if(parentNode)
        {
            Point originInWorld = parentNode->convertToWorldSpace(rect.origin);
            
            Rect rectInWorld = Rect(originInWorld.x,originInWorld.y,rect.size.width,rect.size.height);
            if(rectInWorld.containsPoint(touchPointInWorld) == false)
            {
                return false;
            }
        }
        
    }
    
   // CCSetIterator it = pTouches->begin();
    Touch* touch = pTouch;
	m_beginPoint = touch->getLocation();
    
    Node* parent = getParent();
    Point localPoint = parent->convertToNodeSpace(m_beginPoint);
    Rect boundRect = boundingBox();
    
    bool unmoveAbleFlag = getContentSize().equals(m_contentLayer->getContentSize());// CCSize::CCSizeEqualToSize(getContentSize(),m_contentLayer->getContentSize());
    if(boundRect.containsPoint(localPoint) && unmoveAbleFlag==false) //点击开始在区域内
    {
        m_containBeginTouchPointFlag = true;
        m_2fLastMoveDis = vertex2(0, 0);
        
        sendSelector(SSTE_TOUCH_BEGIN);
       
        if(m_decelerateFlag)
        {
            m_decelerateFlag = false;
            unschedule(schedule_selector(CCScrollLayer::decelerateTick));
            
        }
        moveToEndPosition(false,m_contentLayer->getPosition());
        return true;
    }
    else
    {
        m_containBeginTouchPointFlag = false;
        return false;
    }
}
Ejemplo n.º 11
0
void GameLayer::RockerStopMoveHero()
{
	unschedule(CC_SCHEDULE_SELECTOR(GameLayer::HeroMove));
}
Ejemplo n.º 12
0
void CCScrollLayer::scrollDidEnd(Node* pNode)
{
    unschedule(schedule_selector(CCScrollLayer::actionTick));
    sendSelector(SSTE_ACTION_END);
}
Ejemplo n.º 13
0
void StressTest2::shouldNotLeak(float dt)
{
    unschedule("should_not_leak_key");
    auto sublayer = static_cast<Layer*>( getChildByTag(kTagSprite1) );
    sublayer->removeAllChildrenWithCleanup(true); 
}
Ejemplo n.º 14
0
void NodeTest4::delay4(float dt)
{
    unschedule("delay4_key");
    removeChildByTag(3, false);
}
Ejemplo n.º 15
0
void GameScene::onReducingBonus(float dt)
{
	m_bonusbar->setPercent(m_bonusbar->getPercent()-0.2);

	//倒计时结束,游戏结束,保存游戏分数
	if (m_bonusbar->getPercent() == 0)
	{
		unschedule(schedule_selector(GameScene::onReducingBonus));

		log("game over!");
		publishScore();
		auto scene = GameOverScene::createScene();
		Director::getInstance()->replaceScene(TransitionFade::create(1.0, scene));
	}

	auto fadein = FadeIn::create(0.1);
	auto fadeout = FadeOut::create(0.1);
	CallFunc* call = nullptr;
	//根据倒计时条进度刷新背景
	if (m_bonusbar->getPercent() < 100 && m_bonusbar->getPercent() > 75)
	{
		if (m_bg->getTag() == 100)
			call = nullptr;
		else
		{
			call = CallFunc::create([this](){
				m_bg->setTexture(Director::getInstance()->getTextureCache()->getTextureForKey("bground1.png"));
			});
			m_bg->setTag(100);
		}
	}

	if (m_bonusbar->getPercent() < 75 && m_bonusbar->getPercent() > 50)
	{
		if (m_bg->getTag() == 101)
			call = nullptr;
		else
		{
			call = CallFunc::create([this](){
				m_bg->setTexture(Director::getInstance()->getTextureCache()->getTextureForKey("bground2.png"));
				m_bg->setTag(101);
			});
		}
	}

	if (m_bonusbar->getPercent() < 50 && m_bonusbar->getPercent() > 25)
	{
		if (m_bg->getTag() == 102)
			call = nullptr;
		else
		{
			call = CallFunc::create([this](){
				m_bg->setTexture(Director::getInstance()->getTextureCache()->getTextureForKey("bground3.png"));
				m_bg->setTag(102);
			});
		}
	}

	if (m_bonusbar->getPercent() < 25)
	{
		if (m_bg->getTag() == 103)
			call = nullptr;
		else
		{
			call = CallFunc::create([this](){
				m_bg->setTexture(Director::getInstance()->getTextureCache()->getTextureForKey("bground4.png"));
				m_bg->setTag(103);
			});
		}
	}

	if (call)
	{
		m_bg->runAction(Sequence::create(fadeout, call, fadein, nullptr));
	}
}
Ejemplo n.º 16
0
void SchedulerUpdateFromCustom::stopUpdate(float dt)
{
    unscheduleUpdate();
    unschedule(schedule_selector(SchedulerUpdateFromCustom::stopUpdate));
}
Ejemplo n.º 17
0
void ZwoptexGenericTest::startIn05Secs(float dt)
{
    unschedule(CC_SCHEDULE_SELECTOR(ZwoptexGenericTest::startIn05Secs));
    schedule(CC_SCHEDULE_SELECTOR(ZwoptexGenericTest::flipSprites), 0.5f);
}
Ejemplo n.º 18
0
void HelloWorld::endGame(){
    unscheduleUpdate();
    unschedule(schedule_selector(HelloWorld::addBar));
}
Ejemplo n.º 19
0
void SGCGMovieLayer::constructView()
{
    SGNotificationCenter::sharedNotificationCenter()->addObserver(MSG_CGBATTLE_START, this, callfuncO_selector(SGCGMovieLayer::cgBattleListener));
       s = CCDirector::sharedDirector()->getWinSize();
    
    ResourceManager::sharedInstance()->bindTexture("bg/cgBg.plist", RES_TYPE_LAYER_UI, sg_cgMovieLayer);

    CCSprite *cgBg = CCSprite::createWithSpriteFrameName("cgBg.png");
    cgBg->setAnchorPoint(ccp(0.5, 1));
    cgBg->ignoreAnchorPointForPosition(false);
    cgBg->cocos2d::CCNode::setScaleX(s.width/cgBg->getContentSize().width);
    cgBg->setPosition(ccp(s.width/2, s.height));
    addChild(cgBg);
    
//    SGButton *skipBt = SGButton::createFromLocal("box_btnbg.png", "跳 过", this, menu_selector(SGCGMovieLayer::cgSkipToBattle), CCPointZero, FONT_PANGWA,ccWHITE,32,false,true);
//    skipBt->setPosition(ccp(s.width/2, skipBt->getContentSize().height*2));
//    addBtn(skipBt);
    
    CCLayerColor * blackBg = CCLayerColor::create(ccc4(0, 0, 0, 255), s.width, s.height);
    blackBg->setTouchEnabled(false);
    blackBg->ignoreAnchorPointForPosition(false);
    blackBg->setAnchorPoint(ccp(0, 0));
    blackBg->setPosition(ccp(0, 0));
    this->addChild(blackBg, -100);
    
    scrollRect = CCRectMake(0, s.height*0.2, s.width, s.height/4);
    cgScrollView = SNSScrollView::create(scrollRect);
    cgScrollView->setFrame(scrollRect);
    cgScrollView->setPosition(scrollRect.origin);
    cgScrollView->setHorizontal(false);
    cgScrollView->setVertical(true);
    cgScrollView->setTouchEnabled(false);
    this->addChild(cgScrollView);
    
//    CCSprite *scrollBg = CCSprite::createWithSpriteFrameName("barrack_kuang.png");
//    scrollBg->cocos2d::CCNode::setScale(s.width/scrollBg->getContentSize().width, s.height/4/scrollBg->getContentSize().height);
//    scrollBg->setPosition(ccpAdd(scrollRect.origin, ccp(s.width/2, s.height/8)));
//    addChild(scrollBg);
    
    char *spritData = new char[(int)s.width * (int)s.height *4];
    memset(spritData,0,(int)s.width * (int)s.height *4);
    int spriteDataSize = (int)s.width * (int)s.height*4;
    for (int j=0; j<spriteDataSize; j+=4) {
        spritData[j] = 0;
        spritData[j+1] = 0;
        spritData[j+2] = 0;
        spritData[j+3] = 255;
    }
    
    CCTexture2D *pTexture = new CCTexture2D();
    pTexture->initWithData(spritData, kCCTexture2DPixelFormat_Default, (int)s.width, (int)s.height, s);
    
    finaleSprite = CCSprite::createWithTexture(pTexture);
    finaleSprite->setPosition(CCPointZero);
    finaleSprite->setAnchorPoint(CCPointZero);
    this->addChild(finaleSprite,10,10);
    finaleSprite->setVisible(false);
    finaleSprite->setOpacity(0);
    
    delete [] spritData;
    pTexture->autorelease();
    
    
    this->setTouchEnabled(true);
    
    const char *str[7] = { str_CGMovieLayer_str1,
                         str_CGMovieLayer_str2,
                        str_CGMovieLayer_str3,
                         str_CGMovieLayer_str4,
                        str_CGMovieLayer_str5,
                          str_CGMovieLayer_str6,
                         str_CGMovieLayer_str7};
    
    SGCCLabelTTF *cgMsg = NULL;
    posY =  -20;
    for (int i=0; i<7; i++) {
        cgMsg =  SGCCLabelTTF::create(str[i], FONT_BOXINFO, 34);
        cgMsg->cocos2d::CCNode::setPosition(s.width/2, posY);
        cgScrollView->m_body->addChild(cgMsg);
        posY -= 50;
    }
    moveCgMsgDis = CGMSGMOVEDIS;
    unschedule(schedule_selector(SGCGMovieLayer::moveCgMsgUp));
    if (SGPlayerInfo::sharePlayerInfo()->getCDKeyNeed()==1) {
        
        SGNotificationCenter::sharedNotificationCenter()->addObserver(MSG_CDK, this, callfuncO_selector(SGCGMovieLayer::cdkListener));
        
        ResourceManager::sharedInstance()->bindTexture("sgloginingbox/sgloginingbox.plist", RES_TYPE_LAYER_UI, sg_cgMovieLayer);
//         ResourceManager::sharedInstance()->bindTexture("sgserverlistlayer/sgserverlistlayer.plist",RES_TYPE_LAYER_UI ,sg_registerLayer);
        
        
        box = CCSprite::createWithSpriteFrameName("register_diban.png");
        box->setPosition(SGLayout::getPoint(kMiddleCenter));
        this->addChild(box);

        m_cdk = CCEditBox::create(CCSizeMake(500, 60), CCScale9Sprite::createWithSpriteFrameName("public_kuang_input.png"));
        m_cdk->setPlaceHolder(str_CGMovieLayer_str8);
        m_cdk->setPlaceholderFontColor(ccc3(0x82,0x3e,0x02));
        m_cdk->setMaxLength(10);
        m_cdk->setReturnType(kKeyboardReturnTypeDone);
        m_cdk->setInputMode(kEditBoxInputModeSingleLine);
        m_cdk->setPosition(ccp(box->getContentSize().width*.5,box->getContentSize().height*.48));
//        m_cdk->setDelegate(this);
        box->addChild(m_cdk);
   
        
        
        title = CCSprite::createWithSpriteFrameName("gameactive.png");
        title->setPosition(ccp(box->getContentSize().width*.5,box->getContentSize().height*.8));
        box->addChild(title);
        //确定
        btn = SGButton::create("box_btnbg.png", "public_font_queding.png", this, menu_selector(SGCGMovieLayer::btnclick),CCPointZero,false,true);
        this->addBtn(btn);
        btn->setPosition(ccpAdd(box->getPosition(),ccp(-140,-btn->getContentSize().height*2.5)));
        //取消
        btn2 = SGButton::create("box_btnbg.png", "public_font_quxiao.png", this, menu_selector(SGCGMovieLayer::btnclickcancel),CCPointZero,false,true);
        this->addBtn(btn2);
        btn2->setPosition(ccpAdd(box->getPosition(),ccp(140,-btn->getContentSize().height*2.5)));

        
    }
    else
    {
    schedule(schedule_selector(SGCGMovieLayer::moveCgMsgUp), CGMSGMOVEGAP);
    }
}
Ejemplo n.º 20
0
abandon()
{
	register struct quad	*q;
	register int		i;
	int			j;
	register struct event	*e;

	if (Ship.ship == QUEENE)
		return (printf("You may not abandon ye Faire Queene\n"));
	if (Ship.cond != DOCKED)
	{
		if (damaged(SHUTTLE))
			return (out(SHUTTLE));
		printf("Officers escape in shuttlecraft\n");
		/* decide on fate of crew */
		q = &Quad[Ship.quadx][Ship.quady];
		if (q->qsystemname == 0 || damaged(XPORTER))
		{
			printf("Entire crew of %d left to die in outer space\n",
				Ship.crew);
			Game.deaths += Ship.crew;
		}
		else
		{
			printf("Crew beams down to planet %s\n", systemname(q));
		}
	}
	/* see if you can be exchanged */
	if (Now.bases == 0 || Game.captives < 20 * Game.skill)
		lose(L_CAPTURED);
	/* re-outfit new ship */
	printf("You are hereby put in charge of an antiquated but still\n");
	printf("  functional ship, the Fairie Queene.\n");
	Ship.ship = QUEENE;
	Ship.shipname = "Fairie Queene";
	Param.energy = Ship.energy = 3000;
	Param.torped = Ship.torped = 6;
	Param.shield = Ship.shield = 1250;
	Ship.shldup = 0;
	Ship.cloaked = 0;
	Ship.warp = 5.0;
	Ship.warp2 = 25.0;
	Ship.warp3 = 125.0;
	Ship.cond = GREEN;
	/* clear out damages on old ship */
	for (i = 0; i < MAXEVENTS; i++)
	{
		e = &Event[i];
		if (e->evcode != E_FIXDV)
			continue;
		unschedule(e);
	}
	/* get rid of some devices and redistribute probabilities */
	i = Param.damprob[SHUTTLE] + Param.damprob[CLOAK];
	Param.damprob[SHUTTLE] = Param.damprob[CLOAK] = 0;
	while (i > 0)
		for (j = 0; j < NDEV; j++)
		{
			if (Param.damprob[j] != 0)
			{
				Param.damprob[j] += 1;
				i--;
				if (i <= 0)
					break;
			}
		}
	/* pick a starbase to restart at */
	i = ranf(Now.bases);
	Ship.quadx = Now.base[i].x;
	Ship.quady = Now.base[i].y;
	/* setup that quadrant */
	while (1)
	{
		initquad(1);
		Sect[Ship.sectx][Ship.secty] = EMPTY;
		for (i = 0; i < 5; i++)
		{
			Ship.sectx = Etc.starbase.x + ranf(3) - 1;
			if (Ship.sectx < 0 || Ship.sectx >= NSECTS)
				continue;
			Ship.secty = Etc.starbase.y + ranf(3) - 1;
			if (Ship.secty < 0 || Ship.secty >= NSECTS)
				continue;
			if (Sect[Ship.sectx][Ship.secty] == EMPTY)
			{
				Sect[Ship.sectx][Ship.secty] = QUEENE;
				dock();
				compkldist(0);
				return;
			}
		}
	}
}
Ejemplo n.º 21
0
void ItemTortoiseFly::updateStatus()
{
	if (_status == NORMAL)
	{
		stopAllActions();
		if (_dir == Common::LEFT)
		{
			runAnimation("TortoiseFlyLeft");
		}
		else
		{
			runAnimation("TortoiseFlyRight");

		}
	}
	else if (_status == DROPPING)
	{
		stopAllActions();

		// 设置它下降的速度
		_speedDown = _mario->_speedDown + 10;
		_mario->_speedDown = 10;

		if (_dir == Common::LEFT)
		{
			runAnimation("TortoiseMoveLeft");
		}
		else
		{
			runAnimation("TortoiseMoveRight");
		}
	}
	else if (_status == ONLAND)
	{
		// .....
	}
	else if (_status == SLEEP)
	{
		stopAllActions();
		runAnimation("TortoiseDead");

		scheduleOnce(schedule_selector(ItemTortoiseFly::Recover), 10);
		setGodMode(0.2f);
		// 微调位置
		if (_mario->getPositionX() < getPositionX())
		{
			setPositionX(_mario->getPositionX() + _mario->boundingBox().size.width + 1);
		}
		else
		{
			setPositionX(_mario->getPositionX() - boundingBox().size.width - 1);
		}

	}
	else if (_status == CRAZY)
	{
		unschedule(schedule_selector(ItemTortoiseFly::Recover));
		_speed = 200;
		_speedDown = _speedAcc = 10;
	}
}
Ejemplo n.º 22
0
void Y8950Adpcm::writeReg(byte rg, byte data, const EmuTime &time)
{
	//PRT_DEBUG("Y8950Adpcm: write "<<(int)rg<<" "<<(int)data);
	switch (rg) {
		case 0x07: // START/REC/MEM DATA/REPEAT/SP-OFF/-/-/RESET
			reg7 = data;
			if (reg7 & R07_RESET) {
				playing = false;
			} else if (data & R07_START) {
				playing = true;
				restart();
			}
			
			if (playing) {
				schedule(time);
			} else {
                unschedule(time);
//				Scheduler::instance().removeSyncPoint(this);
			}
			break;

		case 0x08: // CSM/KEY BOARD SPLIT/-/-/SAMPLE/DA AD/64K/ROM 
			romBank = data & R08_ROM;
			addrMask = data & R08_64K ? (1<<17)-1 : (1<<19)-1;
			break;

		case 0x09: // START ADDRESS (L)
			startAddr = (startAddr & 0x7F800) | (data << 3);
			memPntr = 0;
			break;
		case 0x0A: // START ADDRESS (H) 
			startAddr = (startAddr & 0x007F8) | (data << 11);
			memPntr = 0;
			break;

		case 0x0B: // STOP ADDRESS (L)
			stopAddr = (stopAddr & 0x7F807) | (data << 3);
			break;
		case 0x0C: // STOP ADDRESS (H) 
			stopAddr = (stopAddr & 0x007FF) | (data << 11);
			break;


		case 0x0F: // ADPCM-DATA
			// TODO check this
			//if ((reg7 & R07_REC) && (reg7 & R07_MEMORY_DATA)) {
			{
				int tmp = ((startAddr + memPntr) & addrMask) / 2;
				tmp = (tmp < ramSize) ? tmp : (tmp & (ramSize - 1)); 
				if (!romBank) {
					ramBank[tmp] = data;
				}
				//PRT_DEBUG("Y8950Adpcm: mem " << tmp << " " << (int)data);
				memPntr += 2;
				if ((startAddr + memPntr) > stopAddr) {
					y8950.setStatus(Y8950::STATUS_EOS);
				}
			}
			y8950.setStatus(Y8950::STATUS_BUF_RDY);
			break;

		case 0x10: // DELTA-N (L) 
			delta = (delta & 0xFF00) | data;
			step = Y8950::rate_adjust(delta<<GETA_BITS, sampleRate);
			volumeWStep = (int)((double)volume * step / MAX_STEP);
			break;
		case 0x11: // DELTA-N (H) 
			delta = (delta & 0x00FF) | (data << 8);
			step = Y8950::rate_adjust(delta<<GETA_BITS, sampleRate);
			volumeWStep = (int)((double)volume * step / MAX_STEP);
			break;

		case 0x12: { // ENVELOP CONTROL 
			int oldVol = volume;
			volume = (data * ADPCM_VOLUME) >> 8;
			if (oldVol != 0) {
				double factor = (double)volume / (double)oldVol;
				output =     (int)((double)output     * factor);
				sampleStep = (int)((double)sampleStep * factor);
			}
			volumeWStep = (int)((double)volume * step / MAX_STEP);
			break;
		}
		case 0x0D: // PRESCALE (L) 
		case 0x0E: // PRESCALE (H) 
		case 0x15: // DAC-DATA  (bit9-2)
		case 0x16: //           (bit1-0)
		case 0x17: //           (exponent)
		case 0x1A: // PCM-DATA
			// not implemented
			break;
	}
}
Ejemplo n.º 23
0
IFWingNode::~IFWingNode()
{
    unschedule(schedule_selector(IFWingNode::onGameTick));
    CC_SAFE_RELEASE_NULL(animationObj);
}
Ejemplo n.º 24
0
void TimeoutMonitor::cancleMonitor()
{
	CCLOG("%s",__FUNCTION__);
	unschedule(schedule_selector(TimeoutMonitor::timeOutCallback));
}
Ejemplo n.º 25
0
ComboLayer::~ComboLayer()
{
	unschedule(schedule_selector(ComboLayer::update));
}
Ejemplo n.º 26
0
void ZwoptexGenericTest::startIn05Secs(ccTime dt)
{
	unschedule(schedule_selector(ZwoptexGenericTest::startIn05Secs));
	schedule(schedule_selector(ZwoptexGenericTest::flipSprites), 0.5f);
}
////////////////////////////////////////////////////////
//
// PerformanceContainerScene
//
////////////////////////////////////////////////////////
void PerformanceContainerScene::initWithQuantityOfNodes(unsigned int nNodes)
{
    _type = 0;
    //srand(time());
    auto s = Director::getInstance()->getWinSize();

    // Title
    auto label = Label::createWithTTF(title().c_str(), "fonts/arial.ttf", 32);
    addChild(label, 1, TAG_TITLE);
    label->setPosition(Vec2(s.width/2, s.height-50));

    // Subtitle
    std::string strSubTitle = subtitle();
    if(strSubTitle.length())
    {
        auto l = Label::createWithTTF(strSubTitle.c_str(), "fonts/Thonburi.ttf", 16);
        addChild(l, 1, TAG_SUBTITLE);
        l->setPosition(Vec2(s.width/2, s.height-80));
    }

    lastRenderedCount = 0;
    currentQuantityOfNodes = 0;
    quantityOfNodes = nNodes;

    MenuItemFont::setFontSize(65);
    auto decrease = MenuItemFont::create(" - ", [&](Ref *sender) {
		quantityOfNodes -= kNodesIncrease;
		if( quantityOfNodes < 0 )
			quantityOfNodes = 0;

		updateQuantityLabel();
		updateQuantityOfNodes();
        updateProfilerName();
        CC_PROFILER_PURGE_ALL();
        srand(0);
	});
    decrease->setColor(Color3B(0,200,20));
    _decrease = decrease;
    
    auto increase = MenuItemFont::create(" + ", [&](Ref *sender) {
		quantityOfNodes += kNodesIncrease;
		if( quantityOfNodes > kMaxNodes )
			quantityOfNodes = kMaxNodes;

		updateQuantityLabel();
		updateQuantityOfNodes();
        updateProfilerName();
        CC_PROFILER_PURGE_ALL();
        srand(0);
	});
    increase->setColor(Color3B(0,200,20));
    _increase = increase;

    auto menu = Menu::create(decrease, increase, nullptr);
    menu->alignItemsHorizontally();
    menu->setPosition(Vec2(s.width/2, s.height/2+15));
    addChild(menu, 1);

    auto infoLabel = Label::createWithTTF("0 nodes", "fonts/Marker Felt.ttf", 30);
    infoLabel->setColor(Color3B(0,200,20));
    infoLabel->setPosition(Vec2(s.width/2, s.height/2-15));
    addChild(infoLabel, 1, kTagInfoLayer);

    auto menuLayer = new ContainerBasicLayer(true, MAX_LAYER, g_curCase);
    addChild(menuLayer);
    menuLayer->release();

    log("Size of Node: %u\n", sizeof(Node));
    
    int oldFontSize = MenuItemFont::getFontSize();
    MenuItemFont::setFontSize(24);
    
    Vector<cocos2d::MenuItem *> toggleItems;
    
    generateTestFunctions();
    
    CCASSERT(!_testFunctions.empty(), "Should not be empty after generate test functions");

    
    for (const auto& f : _testFunctions)
    {
        toggleItems.pushBack(MenuItemFont::create(f.name));
    }
    
    auto toggle = MenuItemToggle::createWithCallback([this](Ref* sender){
        auto toggle = static_cast<MenuItemToggle*>(sender);
        this->_type = toggle->getSelectedIndex();
        auto label = static_cast<Label*>(this->getChildByTag(TAG_SUBTITLE));
        label->setString(StringUtils::format("Test '%s', See console", this->_testFunctions[this->_type].name));
        this->updateProfilerName();
    }, toggleItems);
    
    toggle->setAnchorPoint(Vec2::ANCHOR_MIDDLE_LEFT);
    toggle->setPosition(VisibleRect::left());
    _toggle = toggle;
    
    auto start = MenuItemFont::create("start", [this](Ref* sender){
        auto director = Director::getInstance();
        auto sched = director->getScheduler();
        
        CC_PROFILER_PURGE_ALL();
        sched->schedule(schedule_selector(PerformanceContainerScene::dumpProfilerInfo), this, 2, false);
        
        this->unscheduleUpdate();
        this->scheduleUpdate();
        this->_startItem->setEnabled(false);
        this->_stopItem->setEnabled(true);
        this->_toggle->setEnabled(false);
        this->_increase->setEnabled(false);
        this->_decrease->setEnabled(false);
    });
    start->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT);
    start->setPosition(VisibleRect::right() + Vec2(0, 40));
    _startItem = start;
    
    auto stop = MenuItemFont::create("stop", [this](Ref* sender){
        auto director = Director::getInstance();
        auto sched = director->getScheduler();
        
        sched->unschedule(schedule_selector(PerformanceContainerScene::dumpProfilerInfo), this);
        
        this->unscheduleUpdate();
        this->_startItem->setEnabled(true);
        this->_stopItem->setEnabled(false);
        this->_toggle->setEnabled(true);
        this->_increase->setEnabled(true);
        this->_decrease->setEnabled(true);
    });
    
    stop->setEnabled(false);
    stop->setAnchorPoint(Vec2::ANCHOR_MIDDLE_RIGHT);
    stop->setPosition(VisibleRect::right() + Vec2(0, -40));
    _stopItem = stop;
    
    auto menu2 = Menu::create(toggle, start, stop, nullptr);
    menu2->setPosition(Vec2::ZERO);
    addChild(menu2);
    
    MenuItemFont::setFontSize(oldFontSize);

    updateQuantityLabel();
    updateQuantityOfNodes();
    updateProfilerName();
}
Ejemplo n.º 28
0
void Snake::sleep(float t){
	unschedule(schedule_selector(Snake::move));
	schedule(schedule_selector(Snake::move), 1 / speed, kRepeatForever, t);
}
Ejemplo n.º 29
0
void Mushroom::createRemove()
{
    unschedule(schedule_selector(Mushroom::createRemove));
    _needToRemove = true;
}
Ejemplo n.º 30
0
void GameScene::updateAutoGo(float delay){
	unschedule(CC_SCHEDULE_SELECTOR(GameScene::updateAutoGo));
	if (!clickRed && isRedTurn){
		aiGostep();
	}
}