TeamInfoBackUI::TeamInfoBackUI() { ResManager* resMgr = ResManager::getManager(); CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCSprite* backG = CCSprite::create(resMgr->getSharedFilePath(g_mainlayerPath+"main_background.png").c_str()); backG->setScale(1382.f/1024.f); backG->setPosition(CCPointMake(winSize.width/2, winSize.height/2)); addChild(backG,-1); int pos[8][2] = {{160,460},{222,218},{1207,313},{458,188},{680,48},{815,265},{998,172},{1241,500}}; for (int i = 1; i < 9; i ++) { CCString *str = CCString::createWithFormat((resMgr->getSharedFilePath()+g_mainlayerPath+"main_xiaoguo_piaofu_%d.png").c_str(),i); CCSprite *oneSpr = CCSprite::create(str->getCString()); MainThingEffect *one = MainThingEffect::create(); one->initWithTexture(oneSpr->getTexture()); //one->setAnchorPoint(CCPointZero); one->setPosition(ccp(pos[i - 1][0],pos[i - 1][1])); addChild(one,-1); one->setTag(i); one->setParent(this); m_sMainThingList.push_back(one); } moveThing(); }
void GameBoard::pushEntities( int x, int y, int x_step, int y_step ) { if ( entity( x, y ).isWalkable() ) { return; } // only push cardinal directions, not in diagonals or idle if ( ! ( ( x_step == 0 && y_step != 0 ) || ( x_step != 0 && y_step == 0 ) ) ) { return; } // normalize to 1 or -1 x_step = ( x_step > 0 ) ? 1 : ( x_step < 0 ) ? -1 : 0; // normalize to 1 or -1 y_step = ( y_step > 0 ) ? 1 : ( y_step < 0 ) ? -1 : 0; // iterate through pushables until we find a walkable int tx = x, ty = y; int pushCount = 0; while (true) { const ZZTEntity &ent = entity( tx, ty ); if ( ent.isWalkable() ) { break; } if ( !ent.isPushable( x_step, y_step ) ) { return; } tx += x_step; ty += y_step; pushCount += 1; } // okay, we're at a walkable. copy everything back now. int px = tx, py = ty; while ( tx != x || ty != y ) { px -= x_step; py -= y_step; if ( entity( px, py ).isThing() ) { moveThing( entity( px, py ).thing(), tx, ty ); } else { ZZTEntity p_ent = entity( px, py ); setEntity( tx, ty, p_ent ); } tx = px; ty = py; } if ( pushCount >= 1 ) { musicStream()->playEvent( AbstractMusicStream::Push ); } setEntity( x, y, ZZTEntity::createEntity( ZZTEntity::EmptySpace, 0x07 ) ); }