本文整理汇总了C++中MapLayer类的典型用法代码示例。如果您正苦于以下问题:C++ MapLayer类的具体用法?C++ MapLayer怎么用?C++ MapLayer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MapLayer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doGameEnd
void GameLayer::doGameEnd(CCNode* pSender){
CCDirector* pDirector = CCDirector::sharedDirector();
CCSize winSize = pDirector->getWinSize();
//stop all acitons
isGameEnded = true;
heroLayer->unscheduleUpdate();
heroLayer->unscheduleAllSelectors();
_enemyAI->unscheduleUpdate();
_enemyAI->unscheduleAllSelectors();
//check game win or not
CCSprite* resultPad = NULL;
if (my_hero->getLife() <= 0){
//game lose
resultPad = CCSprite::create("ui/lose.png");
}
else{
//game win
resultPad = CCSprite::create("ui/win.png");
MapLayer* thisMap = MapLayer::getMap();
thisMap->unlockNextLevel();
thisMap->setLevelAccomp();
}
this->addChild(resultPad, 101);
resultPad->setPosition(ccp(winSize.width / 2,
winSize.height / 2 + resultPad->getContentSize().height / 3));
//disable touches except back to menu
CCLayerColor* maskLayer = CCLayerColor::create(ccc4(255, 255, 255, 160), winSize.width, winSize.height);
this->setZOrder(1);
this->addChild(maskLayer, 100);
backIcon->setZOrder(101);
backIcon->setPosition(ccp(winSize.width / 2, winSize.height / 2 - backIcon->getContentSize().height));
}
示例2: position
/**
* ÄLÄ VITTU KOSKE IKINÄ TÄHÄN
*/
void TileMap::draw(SpriteBatch *batch, SDL_Rect *camera) {
SDL_Rect from;
SDL_Rect viewPoint;
viewPoint.x = (camera->x + camera->w) / tileEngine.tileWidth ;
viewPoint.y = (camera->y + camera->h) / tileEngine.tileHeight ;
from.x = std::max(0, camera->x / tileEngine.tileWidth - 1);
from.y = std::max(0, camera->y / tileEngine.tileHeight - 1);
int toX = std::min(viewPoint.x + 1, tileEngine.width);
int toY = std::min(viewPoint.y + 1 , tileEngine.height);
SDL_Rect to;
to.x = toX;
to.y = toY;
Vector position(0,0);
for (int layer = layers.size()-1; layer >= 0; layer--) {
MapLayer mapLayer = layers[layer];
for (int y = from.y; y < to.y; ++y) {
position.y = y * tileEngine.tileHeight - camera->y;
for (int x = from.x; x < to.x; ++x) {
if (mapLayer.getTile(y,x)->textureX >= 0) {
position.x = x * tileEngine.tileWidth - camera->x;
batch->draw(mapLayer.sheet->sheet, &position, mapLayer.getSource(y,x));
}
}
}
}
}
示例3: GetTilesetFromTileId
void j1Map::Draw()
{
if(map_loaded == false)
return;
//STL CHANGE
list<MapLayer*>::iterator item = data.layers.begin();
for(; item != data.layers.end(); ++item)
{
MapLayer* layer = *item;
if(layer->properties.Get("Nodraw") != 0)
continue;
for(int y = 0; y < data.height; ++y)
{
for(int x = 0; x < data.width; ++x)
{
int tile_id = layer->Get(x, y);
if(tile_id > 0)
{
TileSet* tileset = GetTilesetFromTileId(tile_id);
SDL_Rect r = tileset->GetTileRect(tile_id);
iPoint pos = MapToWorld(x, y);
App->render->Blit(tileset->texture, pos.x, pos.y, &r);
}
}
}
}
}
示例4: GetTilesetFromTileId
void j1Map::Draw()
{
if(map_loaded == false)
return;
p2List_item<MapLayer*>* item = data.layers.start;
for(; item != NULL; item = item->next)
{
MapLayer* layer = item->data;
if(layer->properties.Get("Nodraw") != 0)
continue;
for(int y = 0; y < data.height; ++y)
{
for(int x = 0; x < data.width; ++x)
{
int tile_id = layer->Get(x, y);
if(tile_id > 0)
{
TileSet* tileset = GetTilesetFromTileId(tile_id);
SDL_Rect r = tileset->GetTileRect(tile_id);
iPoint pos = MapToWorld(x, y);
App->render->Blit(tileset->texture, pos.x, pos.y, &r);
}
}
}
}
}
示例5: MapToWorld
void j1Map::Draw()
{
if(map_loaded == false)
return;
// TODO 5: Prepare the loop to draw all tilesets + Blit
MapLayer* layer = data.layers.start->data;
for(int y = 0; y < data.height; ++y)
{
for(int x = 0; x < data.width; ++x)
{
int tile_id = layer->Get(x, y);
if(tile_id > 0)
{
// TODO 10(old): Complete the draw function
TileSet* tileset = data.tilesets.start->data;
SDL_Rect r = tileset->GetTileRect(tile_id);
iPoint pos = MapToWorld(x, y);
App->render->Blit(tileset->texture, pos.x, pos.y, &r);
}
}
}
}
示例6: MapLayer
MapLayer *MapLayer::create(Level *level)
{
MapLayer *mapLayer = new MapLayer();
if (mapLayer->initWithLevel(level)) {
mapLayer->autorelease();
return mapLayer;
}
CC_SAFE_RELEASE(mapLayer);
return NULL;
}
示例7: if
void j1Map::Draw()
{
if(map_loaded == false)
return;
//STL CHANGE
//NOTE: well
//Camera Culling
//----------------------
SDL_Rect cam = App->render->camera;
//----------------------
list<MapLayer*>::iterator item = data.layers.begin();
for(; item != data.layers.end(); ++item)
{
MapLayer* layer = *item;
//NOTE: when drawing navigation map, framerate drops to the half
if (!App->debug)
if(layer->properties.Get("Nodraw") != 0)
continue;
for(int y = 0; y < data.height; ++y)
{
for(int x = 0; x < data.width; ++x)
{
int tile_id = layer->Get(x, y);
if(tile_id > 0)
{
TileSet* tileset = GetTilesetFromTileId(tile_id);
SDL_Rect r = tileset->GetTileRect(tile_id);
iPoint pos = MapToWorld(x, y);
//NOTE: Maybe this has to be implemented on Render.cpp
//NOTE: changing the offset of the tiles because Ric cheated with the original, think about make it general for any map
//NOTE: because of test sake
//----------------------
if (layer->name == "Background")
App->render->Blit(tileset->texture, pos.x - data.tile_width / 2 + tileset->offset_x, pos.y, &r);
else if (layer->name == "Navigation")
App->render->Blit(tileset->texture, pos.x - data.tile_width / 2 , pos.y, &r);
//----------------------
}
}
}
}
}
示例8: new
MapLayer * MapLayer::create(){
if(instance)
return instance;
MapLayer *mapLayer = new (std::nothrow) MapLayer();
if(mapLayer && mapLayer->init()){
mapLayer->autorelease();
instance = mapLayer;
return mapLayer;
}
CC_SAFE_DELETE(mapLayer);
return nullptr;
}
示例9: OnTopographiccalculationSideofstream
void CWet_hView::OnTopographiccalculationSideofstream()
{
MapLayer *pSourceLayer = gpMapWnd->m_pMap->GetLayer( "Cells" );
MapLayer *pToLayer = gpMapWnd->m_pMap->GetLayer("STRGRID");
MapLayer *pFlowDirectionLayer = gpMapWnd->m_pMap->GetLayer("FLOWDIR");
int colToSet = pSourceLayer->GetFieldCol("SIDE");
int thisCount = pSourceLayer->GetRecordCount();
int order = -1;
for ( int i=0; i < thisCount; i++ )
{
Poly *pPoly = pSourceLayer->GetPolygon(i);
float test = pPoly->GetArea();
Vertex centroid = pPoly->GetCentroid();
// int colOrder = pSourceLayer->GetFieldCol("ORDER");
// pSourceLayer->GetData(i,colOrder,order);
int side = -1;
// if (order == 1)
// side = 0;
// else
// {
int row = 0;
int col = 0;
pFlowDirectionLayer->GetGridCellFromCoord( centroid.x, centroid.y, row, col);
side = pFlowDirectionLayer->GetSideOfStream(row, col, pToLayer);
// }
pSourceLayer->SetData(i, colToSet, side);
}
}
示例10: ccc4
KDbool MainScene::initWithMapInformation ( KDint nLevel, KDint nStatus, KDint nLife )
{
if ( !CCLayer::initWithVisibleViewport ( ) )
{
return KD_FALSE;
}
const CCSize& tLyrSize = this->getContentSize ( );
SimpleAudioEngine::sharedEngine ( )->playEffect ( "Sounds/02 start.wav" );
CCLayerColor* pBackColor = CCLayerColor::create ( ccc4 ( 192, 192, 192, 255 ), tLyrSize );
this->addChild ( pBackColor );
CCSpriteFrameCache::sharedSpriteFrameCache ( )->addSpriteFramesWithFile ( "Images/images.plist" );
m_pIconArray = CCArray::create ( );
m_pIconArray->retain ( );
this->iconTank ( );
CCSprite* pLife = CCSprite::createWithSpriteFrameName ( "IP.png" );
pLife->setPosition ( ccp ( 30, tLyrSize.cy - 50 ) );
this->addChild ( pLife );
CCSprite* pLifeIcon = CCSprite::createWithSpriteFrameName ( "p1.png" );
pLifeIcon->setPosition ( ccp ( 20, tLyrSize.cy - 70 ) );
pLifeIcon->setScale ( 0.5f );
this->addChild ( pLifeIcon );
this->showLife ( nLife );
CCSprite* pFlag = CCSprite::createWithSpriteFrameName ( "flag.png" );
pFlag->setPosition ( ccp ( tLyrSize.cx - 50 , tLyrSize.cy - 200 ) );
this->addChild ( pFlag );
this->showLevel ( nLevel );
MapLayer* pMapLayer = MapLayer::create ( nLevel, nStatus, nLife );
pMapLayer->setDelegate ( this );
this->addChild ( pMapLayer );
InputLayer* pInputLayer = InputLayer::create ( );
pInputLayer->setMapLayer ( pMapLayer );
this->addChild ( pInputLayer );
return KD_TRUE;
}
示例11: GetFPDistGrid
void CWet_hView::GetFPDistGrid()
{
MapLayer *pFlowDir = gpMapWnd->m_pMap->GetLayer( "FLOWDIR" );
MapLayer *pStreamGrid = gpMapWnd->m_pMap->GetLayer( "STRGRID" );
MapLayer *pDEM = gpMapWnd->m_pMap->GetLayer( "DEM" );
MapLayer *pFPDistGrid = gpMapWnd->m_pMap->GetLayer( "FLOWDIRX" );
// pFPDistGrid->m_name = "FP DistGrad";
MapLayer *pWatershed = gpMapWnd->m_pMap->GetLayer( "CATCH" );
float flowPathDistance=0.0f;
int flowPathCount=0;
int rows = pDEM->GetRowCount();
int cols = pDEM->GetColCount();
for ( int row=0; row < rows; row++ )
{
for ( int col=0; col < cols; col++ )
{
float distance = pFlowDir->GetDownFlowPathDistance( row, col, pStreamGrid );
pFPDistGrid->m_pData->Set(col, row, (distance));
} // end of: for ( col < cols )
} // end of: for ( row < rows )
pFPDistGrid->SaveGridFile("c:\\research\\maimai\\nato\\fpDist.grd");
}
示例12: LayerProperty
void CusefulView::OnShpFileOpen()
{
// TODO: 在此添加命令处理程序代码
CusefulDoc *pDoc = this->GetDocument();
FeatureClass *pFeatureClass = pDoc->load_shapefile_file();
if ( pFeatureClass == 0 ) return ;
Layers& layers = m_pMapControl->GetLayers();
LayerProperty *pLayerProperty = new LayerProperty(layers.Count()+1,pFeatureClass->GetName());
pLayerProperty->SetRelateDataSet( pFeatureClass);
MapLayer *pMapLayer = new MapLayer( pLayerProperty );
pMapLayer->SetRender( new ShpRender( pMapLayer) );
layers.Add( pMapLayer );
this->m_pMapControl->Reset();
CRect clientRect;
this->GetClientRect(&clientRect);
this->m_pMapControl->ReDraw(clientRect.left,clientRect.top,clientRect.Width(),clientRect.Height());
this->Invalidate(false);
}
示例13: movieSaveDlg
/*
//read Willamette Shapefile
//read data with 365 rows and 9 cols. 1 column for each major subwatershed (minus the middle Willamette, for which we don't have data. 1 row for each day in year
//for each day, classify map according to data
//append to avi file
//finish
BOOL m_saveEmfOutput = TRUE;
if (m_saveEmfOutput)
{
numMovies = 1;
movieFrameRate = 30;
AVIGenerators = new CAVIGenerator*[numMovies]; // array of pointers to AVI generators
auxMovieStuff = new AuxMovieStuff[numMovies];
CDC* dc = gpView->GetWindowDC();
// get the window's dimensions
CRect rect;
gpView->GetWindowRect(rect);
for(int i = 0; i < numMovies; i++)
{
// get output filename from user
CFileDialog movieSaveDlg(FALSE, "avi", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Movie Files (*.avi)|*.avi");
CString movieFileName;
if (movieSaveDlg.DoModal() == IDOK)
{
movieFileName = movieSaveDlg.GetPathName();
}
// need to handle canceling out of the file dialog box somehow
AVIGenerators[i] = new CAVIGenerator(movieFileName, (CView*)gpView, movieFrameRate);
AVIGenerators[i]->InitEngine();
auxMovieStuff[i].bitmapDC.CreateCompatibleDC(dc);
auxMovieStuff[i].bitmap.CreateCompatibleBitmap(dc, rect.Width(), rect.Height());
auxMovieStuff[i].bitmapDC.SelectObject(&auxMovieStuff[i].bitmap);
auxMovieStuff[i].bi.bmiHeader = *AVIGenerators[i]->GetBitmapHeader();
auxMovieStuff[i].lpbi = &auxMovieStuff[i].bi;
auxMovieStuff[i].bitAddress = new BYTE[3*rect.Width()*rect.Height()];
}
gpView->ReleaseDC(dc);
}
ASSERT ( gpMapWnd != NULL );
ASSERT ( gpMapWnd->m_pMap != NULL );
gpMapWnd->m_pMap->AddShapeLayer("c:\\research\\willamette\\will2.shp", true);
MapLayer *pWill = gpMapWnd->m_pMap->GetLayer(0);
FDataObj pAsciiData = FDataObj();
pAsciiData.ReadAscii("c:\\research\\willamette\\willINDI.csv", ',');
int numDays = pAsciiData.GetRowCount();
int numWshed = pAsciiData.GetColCount()-1;
float ti = -1.0f;
gpMapWnd->m_pScatterPrecip = gpMapWnd->AllocateScatter( &pAsciiData, 0 );
gpMapWnd->m_pScatterPrecip->RedrawWindow();
for (int i=0;i<numDays;i++) // for each day of the year (or row in the data)
{
int numSheds = pWill->m_pData->GetRowCount();
float time = -1.0f;
pAsciiData.Get(0,i,time);
gpMapWnd->m_pScatterPrecip->UpdateCurrentPos( time );
//gpMapWnd->m_pScatterPrecip->RedrawWindow();
for (int j=0;j<numSheds;j++) // go through each watershed (there are 12 of them)
{
float value = -1.0f; // and stick the data from pAsciiData into the datatable
pAsciiData.Get(j+1,i,value); //dischargeValue
pWill->SetData(j,pWill->GetFieldCol("EXTRA_2"),value); //add the value to the correct column in the Maplayer
}
CString msg;
COleDateTime t( time );
CString s = t.Format("%m/%d" );
msg.Format( "Completed %s" , s );
gpMain->SetStatusMsg( msg );
pWill->SetBinColorFlag( BCF_BLUEGREEN );
pWill->SetBins( -0.2, 0.4, 20 );
pWill->SetActiveField( pWill->GetFieldCol( "EXTRA_2" ) );
pWill->ClassifyData();
if ( gpMapWnd != NULL )
gpMapWnd->RefreshList();
gpMapWnd->m_pMapList->RedrawWindow();
CDC *dc = gpMapWnd->m_pMap->GetDC();
gpMapWnd->m_pMap->DrawMap(*dc);
gpMapWnd->m_pMap->ReleaseDC(dc);
if (m_saveEmfOutput)
{
CDC* dc = gpView->GetWindowDC();
CRect rect;
gpView->GetWindowRect(rect);
for(int i = 0; i < numMovies; i++)
{
// copy from the application window to the new device context (and thus the bitmap)
BOOL blitSuc = auxMovieStuff[i].bitmapDC.BitBlt(0, 0,
rect.Width(),
//.........这里部分代码省略.........
示例14: init
bool GameScene::init(){
if (!Scene::initWithPhysics())
{
return false;
}
SimpleAudioEngine::getInstance()->rewindBackgroundMusic();
//英雄层
HeroLayer *herolayer = HeroLayer::create();
herolayer->setName("herolayer");
this->addChild(herolayer,3);
//显示边框,注释了就不显示了
//this->getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
//负数为添加向下的加速度
this->getPhysicsWorld()->setGravity(Vec2(0,-1100));
//可视区域大小
Size visSize = Director::getInstance()->getVisibleSize();
//背景图片
Sprite *bg = Sprite::create("bg19a.jpg");
bg->setScale(2);
bg->setPosition(Vec2(visSize.width/2,visSize.height/2));
this->addChild(bg);
//创建Edge
Edge *edge = Edge::create();
//设置边界为整个可是区域
edge->setPosition(visSize.width/2,visSize.height/2);
//设置可以参与碰撞
//edge->getPhysicsBody()->setContactTestBitmask(1);
//添加到 层上面
this->addChild(edge);
//控制层
ControlLayer *controller = ControlLayer::create();
controller->setName("controller");
this->addChild(controller,9);
//添加 敌人层
auto enemyLayer = EnemyLayer::create();
enemyLayer->setName("enemylayer");
this->addChild(enemyLayer,3);
//地图
MapLayer *maplayer = MapLayer::create();
maplayer->setName("maplayer");
this->addChild(maplayer,0);
//逻辑层
LogicLayer *logic = LogicLayer::create();
this->addChild(logic);
//添加动画层
AnimateLayer * animatelayer = AnimateLayer::create();
this->addChild(animatelayer);
//怪物AI层
auto enemyAILayer = EnemyAILayer::create();
this->addChild(enemyAILayer);
//创建一个底面
auto background = Sprite::create();//就是一个精灵
background->setTag(2001);
background->setPhysicsBody(PhysicsBody::createBox(Size(visSize.width,74)));
background->setTextureRect(Rect(0,0,visSize.width,74));//设置纹理的 宽 高
background->getPhysicsBody()->setCategoryBitmask(16);
background->getPhysicsBody()->setCollisionBitmask(31);
background->getPhysicsBody()->setContactTestBitmask(0);
background->setPosition(visSize.width/2,5);//设置地板的 位置
background->getPhysicsBody()->setDynamic(false);
background->setOpacity(0);//设置透明度为0
this->addChild(background);
//创建积分层
ScoreLayer *scoreLayer = ScoreLayer::create();
scoreLayer->setName("scoreLayer");
this->addChild(scoreLayer,9);
SkillLayer *skill = SkillLayer::create();
skill->setName("skilllayer");
this->addChild(skill,9);
return true;
}
示例15: OnTopographiccalculationMeanwatershedelevation
void CWet_hView::OnTopographiccalculationMeanwatershedelevation()
{
MapLayer *pFlowDir = gpMapWnd->m_pMap->GetLayer( "FLOWDIR" );
MapLayer *pStreamGrid = gpMapWnd->m_pMap->GetLayer( "STRGRID" );
MapLayer *pDEM = gpMapWnd->m_pMap->GetLayer( "DEM" );
MapLayer *pFPDistGrid = gpMapWnd->m_pMap->CloneLayer( *pDEM );
pFPDistGrid->m_name = "FP DistGrad";
MapLayer *pWatershed = gpMapWnd->m_pMap->GetLayer( "Cells" );
MapLayer *pStreamV = gpMapWnd->m_pMap->GetLayer("Streams");
int method = 2;
// the third parameter is the method to use. a 1 simply returns the average fpdist for each polygon
// a two returns the entire fp distribution
int watershedCount = pWatershed->GetRecordCount();
int reachCount = pStreamV->GetRecordCount();
gpHydroModel->m_fpDistributionArray.SetSize(reachCount);
gpHydroModel->m_fpDistributionArrayStream.SetSize(reachCount);
for (int i=0; i < reachCount; i++ )
{
Poly *pStreamPoly = pStreamV->m_polyArray[i];
int streamID;
gpHydroModel->m_pStreamLayer->GetData(i,pStreamV->m_pData->GetCol("HYDRO_ID"), streamID);
for ( int j=0; j < watershedCount; j++ )//this should be for each reach
{
Poly *pThisPoly = pWatershed->m_polyArray[j];
int watershedID;
gpHydroModel->m_pCellLayer->GetData(j,pWatershed->m_pData->GetCol("HYDRO_ID"), watershedID);
if (watershedID==streamID) // this polygon is in the current reach
{
Poly *pThisPoly = pWatershed->m_polyArray[j];
float flowPathDistance=0.0f;
int flowPathCount=0;
float flowPathGradient = 0.001f;
int rows = pDEM->GetRowCount();
int cols = pDEM->GetColCount();
for ( int row=0; row < rows; row++ )
{
for ( int col=0; col < cols; col++ )
{
float x = 0;
float y = 0;
pDEM->GetGridCellCenter(row, col, x, y);
Vertex point;
point.x = x;
point.y = y; ///the stream grid is smaller than the flowdir grid
if (pThisPoly->IsPointInPoly(point))
{
int flowPathCellCount=0;
float distance = pFlowDir->GetDownFlowPathDistance( row, col, pStreamGrid );
float gradient = pFlowDir->GetDownFlowPathGradient(row,col,pStreamGrid,pDEM,flowPathCellCount);
gradient=gradient/flowPathCellCount;
float dist_grad = distance/gradient;
if (distance==pFlowDir->GetNoDataValue())
{
dist_grad = pFlowDir->GetNoDataValue();
gradient = pFlowDir->GetNoDataValue();
}
pFPDistGrid->m_pData->Set(col, row, (distance/gradient));
if (method==1)// we just want the average fpdistance
{
flowPathGradient +=gradient;
flowPathDistance +=distance;
flowPathCount++;
}
if (method==2)// we want to maintain the entire distribution
{
int dist = (int)(distance/gradient);
gpHydroModel->m_fpDistributionArray[i].Add(dist);
}
}
} // end of: for ( col < cols )
} // end of: for ( row < rows )
} // end of : if watershed==streamID
}// end of j (watershedCount)
// we have found all the flowpaths in the jth reach, but want to now find the median value of that distribution
float median=-1;
if (method==2)
{
int temp=-1;
for (int bottom=gpHydroModel->m_fpDistributionArray[i].GetCount()-1; bottom>0;bottom--)
{
for (int position=0;position<bottom;position++)
{
int val = gpHydroModel->m_fpDistributionArray[i][position+1];
int val2 = gpHydroModel->m_fpDistributionArray[i][position];
if (val < val2)
{
int temp2 = gpHydroModel->m_fpDistributionArray[i][position];
gpHydroModel->m_fpDistributionArray[i][position] = gpHydroModel->m_fpDistributionArray[i][position+1];
gpHydroModel->m_fpDistributionArray[i][position+1] = temp2;
}
}
}
if (gpHydroModel->m_fpDistributionArray[i].GetCount()<=1)//there were no watersheds for this reach
{
median = 0.0f;
}
else
//.........这里部分代码省略.........