本文整理汇总了C++中CCTMXLayer::boundingBox方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTMXLayer::boundingBox方法的具体用法?C++ CCTMXLayer::boundingBox怎么用?C++ CCTMXLayer::boundingBox使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTMXLayer
的用法示例。
在下文中一共展示了CCTMXLayer::boundingBox方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
bool CMGameMap::Init(CMReceiver* pReceiver,enumMarioLevel &eMarioLevel)
{
do
{
//初始化成员变量
m_fDropSpeedPlus = 0;
m_fJumpSpeed = 0;
m_bIsLeftKeyDown = false;
m_bIsRightKeyDown = false;
m_bIsJumpKeyDown = false;
m_bIsFireKeyDown = false;
m_bIsHeroDead = false;
m_pReceiver = pReceiver;
m_bNeedResetStage = false;
//初始化游戏对象数组
m_pArrayItems = CCArray::create();
m_pArrayItems->retain();
m_pArrayMonsters = CCArray::create();
m_pArrayMonsters->retain();
m_pArrayBlocks = CCArray::create();
m_pArrayBlocks->retain();
m_pArrayFireBall = CCArray::create();
m_pArrayFireBall->retain();
//初始化Mario
CMMario* pMario = CMMario::CreateHero(this,eMarioLevel);
CC_BREAK_IF(pMario==NULL);
pMario->setPosition(TileMapPosToTileMapLayerPos(ccp(2,11)));
addChild(pMario,enZOrderFront,enTagMario);
//pMario->SetStatus(enMarioStatusBig);
//隐藏原落坑判断层
CCTMXLayer* pTrapLayer = layerNamed("trap");
CC_BREAK_IF(pTrapLayer==NULL);
pTrapLayer->setVisible(false);
//初始化显示金币
CCTMXLayer* pCoinLayer = layerNamed("coin");
CC_BREAK_IF(pCoinLayer==NULL);
pCoinLayer->setVisible(false);
//获得地图的瓦片数量
int nMapHorizontalTileNum = pCoinLayer->boundingBox().size.width/getTileSize().width;
int nMapVerticalTileNum = pCoinLayer->boundingBox().size.height/getTileSize().height;
//遍历每片瓦片,寻找金币,建立并加入金币集合
for (int i = 0;i<nMapHorizontalTileNum;i++)
{
for (int j = 0;j<nMapVerticalTileNum;j++)
{
if (TileMapPosToTileType(ccp(i,j))==enTileTypeCoin)
{
//将瓦片地图坐标转换为瓦片地图层坐标
CCPoint CoinTileMapLayerPos = TileMapPosToTileMapLayerPos(ccp(i,j));
CMItemCoin* pCoin = CMItemCoin::CreateItemIcon(CoinTileMapLayerPos,getTileSize(),pMario,this);
if (pCoin==NULL)
{
CCLog("Coin init Error!");
}
pCoin->setPosition(CoinTileMapLayerPos);
pCoin->setAnchorPoint(ccp(0,0));
m_pArrayItems->addObject(pCoin);
addChild(pCoin);
}
}
}
//初始化怪物显示
CCTMXObjectGroup* pObjectLayer = objectGroupNamed("objects");
CC_BREAK_IF(pObjectLayer==NULL);
CCArray *ObjectArray = pObjectLayer->getObjects();
CCDictionary *pDic = NULL;
for (unsigned int i = 0; i < ObjectArray->count(); i++)
{
pDic = (CCDictionary *)ObjectArray->objectAtIndex(i);
int PosX = ((CCString*)pDic->objectForKey("x"))->intValue();
int PosY = ((CCString*)pDic->objectForKey("y"))->intValue();
PosY -= this->getTileSize().height;
CCPoint TileXY = ccp(PosX, PosY);
CCString *strName = (CCString*)pDic->objectForKey("name");
CCString *strType = (CCString*)pDic->objectForKey("type");
// 进行怪物的初始化,先根据名字来判断是不是enemy,再细分enemy类型
if (strName->m_sString == "enemy")
{
if (strType->m_sString == "mushroom")
{
CMMonsterMushrooms *pMonster = CMMonsterMushrooms::CreateMonsterMushrooms(TileXY,pMario,this,this);
if (pMonster==NULL)
{
CCLog("pMonster==NULL!");
}
pMonster->setPosition(ccp(TileXY.x,TileXY.y));
pMonster->setAnchorPoint(ccp(0,0));
m_pArrayMonsters->addObject(pMonster);
addChild(pMonster,enZOrderFront);
}
if (strType->m_sString == "tortoise")
{
CMMonsterTortoise *pMonster = CMMonsterTortoise::CreateMonsterTortoise(TileXY,pMario,this,this);
//.........这里部分代码省略.........