Exemplo n.º 1
0
//LEVEL SETUP
void Level::createLevel(std::string mapPath){
	//PHYSICS WORLD SETUP
	world = getScene()->getPhysicsWorld();
	world->setGravity(Vec2(0.0f, -980.0f));
	world->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
	//PARALLAX-MAP SETUP
	auto parallax = createParallax(mapPath);
	addChild(parallax); //SCENE { level { parallax { map } }
	//TILED MAP PARSING
	prepareLayers();
	addObjects(); //SCENE { level {  parallax { player } } }
}
Exemplo n.º 2
0
void TileMapLayer::createWithTMX(const char* tmxFile)
{
	// create a TMX map --- WARNING : if tsx path in the tmx file is subclass of Resources, libs can't find *.tsx, *.png
	map = TMXTiledMap::create(tmxFile);
	prepareLayers();
	addChild(map);

	// All the tiles by default will be aliased. If you want to create anti-alias tiles, you should do:
	// iterate over all the "layers" (atlas sprite managers)
	// and set them as 'antialias' 
	Array * pChildrenArray = map->getChildren();
	SpriteBatchNode* child = NULL;
	Object* pObject = NULL;

	CCARRAY_FOREACH(pChildrenArray, pObject)
	{
		child = (SpriteBatchNode*)pObject;

		if(!child)
			break;

		child->getTexture()->setAntiAliasTexParameters();
	}
Exemplo n.º 3
0
Scene* Level::createSceneWithMap(std::string mapPath){
	auto scene = Scene::createWithPhysics();

	auto panel = GamePanel::createLayer();
	scene->addChild(panel, 1, panelTag);

	auto layer = Level::create();
	scene->addChild(layer, 0, levelTag);
	//PHYSICS WORLD SETUP
	layer->world = scene->getPhysicsWorld();
	layer->world->setGravity(Vec2(0.0f, -980.0f));
	layer->world->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
	//TILED MAP SETUP
	layer->map = TMXTiledMap::create(mapPath);
	for (const auto& child : layer->map->getChildren()){
		static_cast<SpriteBatchNode*>(child)->getTexture()->setAntiAliasTexParameters();
	}
	layer->addChild(layer->map);
	//TILED MAP PARSING
	layer->prepareLayers();
	layer->addObjects();

	return scene;
}