예제 #1
0
void LogicLayer::bulletvsBarrer()
{   
	auto scene = dynamic_cast<GameScene *>(Director::getInstance()->getRunningScene());
	auto map = dynamic_cast<MapLayer *>(scene->getChildByName("map"));
	/*auto sp = this->getChildByTag(1);
	auto t = map->checkIsNode(sp->getPosition());
	log("%d",t);*/
	//×Óµ¯ºÍÕÏ°­
	auto tankbu = BulletManager::getInstance()->getTankBulletManager();
	auto enemybu = BulletManager::getInstance()->getEnemyBulletManger();
	for (auto titer = tankbu.begin();titer!=tankbu.end();titer++)
	{    auto bu = (*titer);
		if (map->checkIsNode(bu->getPosition()))
		{
			if (map->checkNodeBreak(bu->getPosition()))
			{
				map->breakNode(bu->getPosition());	
			}
			bu->remove();
		}
	}
	for (auto titer = enemybu.begin();titer!=enemybu.end();titer++)
	{    auto bu = (*titer);
	if (map->checkIsNode(bu->getPosition()))
	{
		if (map->checkNodeBreak(bu->getPosition()))
		{
			map->breakNode(bu->getPosition());
			
		}
		bu->remove();
	}
	}
}
예제 #2
0
// 将该点的精灵移出, 因为受到子弹攻击
bool MapLayer::breakNode(Vec2 position){
	if (checkIsNode(position)&&checkNodeBreak(position)&&!checkNodeWrite(position)){
	
	Vec2 towerCoord = converTotileCoord(position + Vec2(0,0));//地图坐标
	 
	auto sptoBreak = bgLayer->tileAt(towerCoord);
	if (bgLayer->getTileGIDAt(towerCoord) == 11 || bgLayer->getTileGIDAt(towerCoord) == 12 || bgLayer->getTileGIDAt(towerCoord) == 25 || bgLayer->getTileGIDAt(towerCoord) == 26){
		count--;
	}
	if (sptoBreak){
		sptoBreak->removeFromParentAndCleanup(true);
		
	}
	 
	}
	return true;
}