码迷,mamicode.com
首页 > 其他好文 > 详细

Cocos2d-x 3.6Terrain地图用法

时间:2015-05-04 18:04:09      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:

//创建摄像机

 _camera = Camera::createPerspective(60,visibleSize.width/visibleSize.height,0.1,800);

 _camera->setCameraFlag(CameraFlag::USER1);

 _camera->setPosition3D(Vec3(-1,1.6,4));

 addChild(_camera);


//分别对应红,绿,蓝,黑色背景的图片资源

Terrain::DetailMap r("TerrainTest/dirt.jpg"),g("TerrainTest/Grass2.jpg"),b("TerrainTest/road.jpg"),a("TerrainTest/GreenSkin.jpg");

//一个参数是高度图,用来生成地图高度;第二个参数是地图贴图,用后面4张图片来生成对应的地图纹理

Terrain::TerrainData data("TerrainTest/heightmap16.jpg","TerrainTest/alphamap.png",r,g,b,a);

//创建Terrain地图
_terrain = Terrain::create(data,Terrain::CrackFixedType::SKIRT);
_terrain->setLODDistance(3.2,6.4,9.6);
_terrain->setMaxDetailMapAmount(4);
addChild(_terrain);
_terrain->setCameraMask(2);

 _terrain->setDrawWire(false);
auto listener = EventListenerTouchAllAtOnce::create();

listener->onTouchesMoved = CC_CALLBACK_2(TerrainSimple::onTouchesMoved, this);
eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);

Cocos2d-x 3.6Terrain地图用法

标签:

原文地址:http://blog.csdn.net/hp_vc/article/details/45483361

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!