Map usage of Cocos2d-x 3.6Terrain

Source: Internet
Author: User

Map usage of Cocos2d-x 3.6Terrain

// Create a camera

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

_ Camera-> setCameraFlag (CameraFlag: USER1 );

_ Camera-> setPosition3D (Vec3 (-1, 1.6, 4 ));

AddChild (_ camera );

 

// Image resources corresponding to the red, green, blue, and black backgrounds

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

// A parameter is a height chart used to generate the map height. The second parameter is a map texture. The next four images are used to generate the corresponding map texture.

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

// Create a Terrain map
_ 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 );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.