void Level::update(float dt) { if (_gameOver) { return; } _player->updatePosition(dt); checkForWin(); checkForAndResolveCollisions(_player); handleCollectCoins(_player); setViewpointCenter(_player->getPosition()); }
void GameLevelLayer::update(float delta) { if (m_isGameOver) { return; } if (m_pPlayer) { m_pPlayer->update(delta); handleHazardCollisions(m_pPlayer); checkForWin(); checkForAndResolveCollisions(m_pPlayer); setViewpointCenter(m_pPlayer->getPosition()); } }
void Hero::move(int i) { if (isDead) {return; } float targetX=this->getPositionX()+i+46; for (float j=this->getPositionY();j<=(46+this->getPositionY());j++) { if (checkCollisionOnly(ccp(targetX,j))==kWall) { i=0; } } float targetX2=this->getPositionX()+i; for (float j=this->getPositionY();j<=(46+this->getPositionY());j++) { if (checkCollisionOnly(ccp(targetX2,j))==kWall) { i=0; } } this->setPosition(this->getPositionX()+1*i,this->getPositionY()); setViewpointCenter(this->getPosition()); hspeed=i; if (!isanimate&&i!=0&&isJumpDone) { AnimationKey key; if (i<0) { key=aLeft; }else { key=aRight; } CCAnimation *animation=sAnimationMgr->getAnimation(key); CCFiniteTimeAction* actionMoveDone=CCCallFuncN::create(this,callfuncN_selector(Hero::animateDone)); heroSprite->runAction(CCSequence::create(CCAnimate::create(animation),actionMoveDone,NULL)); isanimate=true; } }