本文整理汇总了C++中CCTMXLayer::getLayerSize方法的典型用法代码示例。如果您正苦于以下问题:C++ CCTMXLayer::getLayerSize方法的具体用法?C++ CCTMXLayer::getLayerSize怎么用?C++ CCTMXLayer::getLayerSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCTMXLayer
的用法示例。
在下文中一共展示了CCTMXLayer::getLayerSize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getEnemiesListFromLayer
CCArray* LoadLevelEnemies::getEnemiesListFromLayer(CCTMXTiledMap *tilemap,
Player *player) {
CCTMXLayer* layer = tilemap->layerNamed("enemies");
CCSize layersize = layer->getLayerSize();
CCLOG("%s \n", "setEnemiesTilesInformation");
CCArray *enemieArray = CCArray::create();
CCDictionary* enemiesDictionary = PersistenceAux::getEnemyData();
CCLOG("Enemy data loaded");
for (int x = 0; x < layersize.width; x++) {
for (int y = 0; y < layersize.height; y++) {
unsigned int tmpgid = layer->tileGIDAt(ccp(x, y));
if (tmpgid != 0) {
CCSprite* tile = layer->tileAt(ccp(x, y));
CCRect box = tile->boundingBox();
CCPoint boxsize = ccp(box.size.width, box.size.height);
CCPoint tilePosition = ccpAdd(tile->getPosition(),
ccpMult(boxsize, 0.5));
layer->removeTileAt(ccp(x, y));
// create the enemy directly
CCDictionary* tileProperties = tilemap->propertiesForGID(
tmpgid);
CCLOG("%s \n", "dictionary for enemies properties");
CCString* enemyName = (CCString*) tileProperties->objectForKey(
"name");
CCLOG("Enemy name %s \n", enemyName->getCString());
CCDictionary* enemyProperties =
(CCDictionary *) enemiesDictionary->objectForKey(
enemyName->getCString());
CCLOG("Enemy prop. Dictionary size %d \n",
enemyProperties->count());
CCLOG("Enemy Position x %d \n", tilePosition.x);
CCLOG("************** PLIST ****************** \n");
CCLOG("SPEED %s",
((CCString*) enemyProperties->objectForKey("speed"))->getCString());
CCLOG("JUMPFORCE %s",
((CCString*) enemyProperties->objectForKey("jump"))->getCString());
CCLOG("SIGHT %s",
((CCString*) enemyProperties->objectForKey("sight"))->getCString());
CCLOG("DIFICULT %s",
((CCString*) enemyProperties->objectForKey("dificult"))->getCString());
CCLOG("DEFAULT IMAGE %s",
((CCString*) enemyProperties->objectForKey(
"defaultimage"))->getCString());
CCLOG("************** PLIST END ****************** \n");
MeeleEnemy* enemy = MeeleEnemy::create(
(CCString*) enemyProperties->objectForKey(
"defaultimage"),
(CCString*) enemyProperties->objectForKey("dificult"),
(CCString*) enemyProperties->objectForKey("jump"),
(CCString*) enemyProperties->objectForKey("sight"),
(CCString*) enemyProperties->objectForKey("speed"),
tilePosition, enemyName,
(CCString*) enemyProperties->objectForKey("damage")
);
CCLOG("%s \n", "Initializing enemies");
enemy->initMeeleEnemy(player);
CCLOG("%s \n", "Add enemies to enemy array");
enemieArray->addObject(enemy);
}
}
}
return enemieArray;
}