//コマを移動する void GameScene::moveBlock() { //コマ種類のループ vector<kBlock>::iterator it1 = blockTypes.begin(); while (it1 != blockTypes.end()) { //各種類のコマ数分のループ list<int>::iterator it2 = m_blockTags[*it1].begin(); while (it2 != m_blockTags[*it1].end()){ BlockSprite* blockSprite = (BlockSprite*)m_background->getChildByTag(*it2); int nextPosX = blockSprite->getNextPosX(); int nextPosY = blockSprite->getNextPosY(); if(nextPosX != -1 || nextPosY!=-1) { //新しいタグをセットする int newTag = getTag(nextPosX, nextPosY); blockSprite->initNextPos(); blockSprite->setTag(newTag); //タグ一覧の値も新しいタグに変更する *it2 = newTag; //アニメーションをセットする MoveTo* move = MoveTo::create(MOVING_TIME, getPosition(nextPosX,nextPosY)); blockSprite->runAction(move); } it2++; } it1++; } }
void GameScene::moveBlock() { vector<kBlock>::iterator it1 = blockTypes.begin(); while( it1 != blockTypes.end() ) { list<int>::iterator it2 = m_blockTags[*it1].begin(); while( it2 != m_blockTags[*it1].end() ) { BlockSprite* blockSprite = (BlockSprite*)m_background->getChildByTag( *it2 ); int nextPosX = blockSprite->getNextPosX(); int nextPosY = blockSprite->getNextPosY(); if( nextPosX != -1 || nextPosY != -1 ) { int newTag = getTag( nextPosX, nextPosY ); blockSprite->initNextPos(); blockSprite->setTag( newTag ); *it2 = newTag; CCMoveTo* move = CCMoveTo::create( MOVING_TIME, getPosition( nextPosX, nextPosY ) ); blockSprite->runAction( move ); } it2++; } it1++; } }
// コマを移動する (移動するコマに対して移動先の情報をセットし、アクションをセット) void Game::moveBlock() { // コマ種類のイテレーター vector<kBlock>::iterator it1 = blockTypes.begin(); // コマ種類のループ while (it1 != blockTypes.end()) { //各種類のコマ数分のループ list<int>::iterator it2 = m_blockTags[*it1].begin(); while (it2 != m_blockTags[*it1].end()) { // コマの取得 BlockSprite* blockSprite = (BlockSprite*)m_background->getChildByTag(*it2); // 移動先のインデックス取得 int nextPosX = blockSprite->getNextPosX(); int nextPosY = blockSprite->getNextPosY(); // 移動先がいるかの判定 if (nextPosX != -1 || nextPosY != -1) { // 移動先のインデックスより新しいタグを生成 int newTag = getTag(nextPosX, nextPosY); // 移動先の情報の初期化 blockSprite->initNextPos(); // コマに新しいタグをセット blockSprite->setTag(newTag); // タグ一覧の値も新しいタグに変更する *it2 = newTag; // アニメーションを生成 MoveTo* move = MoveTo::create(MOVING_TIME, getPosition(nextPosX, nextPosY)); // アニメーションをセット blockSprite->runAction(move); } it2++; } it1++; } }
void GameScene::setNewPosition1(int tag, PositionIndex posIndex ) { BlockSprite* blockSprite = (BlockSprite*)m_background->getChildByTag( tag ); int nextPosY = blockSprite->getNextPosY(); if( nextPosY == -1 ) { nextPosY = posIndex.y; } blockSprite->setNextPos( posIndex.x, --nextPosY ); }