Cocos2d-x Study Notes (22) -- map use 2 (TMX) -- Z-Order, AnchorPoin, anti-sawtooth

Source: Internet
Author: User


Concept 1: Z-Order
Z-Order sometimes writes zorder, which refers to the hierarchical relationship between objects. For example, when we make a ppt, some of them are illustrated, and the text needs to be on the image, we can set the text position to "the top layer ", at this time, we are changing its Z-Order. Here I am not talking about this. In some mobile games, we often see that some of the players' bodies are covered by these objects when they pass through some grass or forest. This effect is related to the Z-Order I am talking about now. By setting the hierarchy between grass, forest, and players, we can achieve this effect of "covering. These levels can be completed when you edit the map (using the Tiled tool together ). Next I will use the map Resources (samples \ TestCpp \ Resources \ TileMaps \ cocos2d-x) in the examples of iso-test-zorder.tmx (2.0.2) for analysis:

We can. There are four layers under the layers column, namely trees3, trees2, trees1, and grass. Because the four layers are displayed on one screen, we cannot distinguish the content of each layer. Next I will set the transparency of each layer so that everyone can distinguish each layer:
The first is trees1:

Trees2:

Trees3:

Grass:

 
Now, the content of each layer is clear at a glance. For players in the game, we can check the player position at no time and set the Z-Order value of the player in the map so that the players can travel between the forests. Actually, I don't know if you are using addChild (????, ???) The second parameter is to set the ZOrder of the object, that is, the hierarchical relationship between objects is determined when the object is added. If we want to change the zOrder value of an object in the future, we can use:
RecorderChild (sprite, zOrder );
The first parameter is the CCSprite * pointer object.
The second is the zOrder value of the object.

 

Concept 2: AnchorPoint
If we do not change the anchorPoint of the genie, the default AnchorPoint (0.5, 0.5) is the central location of the genie. Below I will give the location of several common coordinates:
(0, 0) corresponds to the lower left corner
(0.5, 0.5) Corresponding Center
() Corresponds to the upper right corner
The Green Point is anchorPoint, And the anchorPoint of the three elves correspond to the above three situations respectively:

When we set the rotate rotation action for the genie, each genie rotates around its own anchorPoint. Similarly, when we set the position of the genie, the reference point we use is also the anchorPoint, that is, the position we set is the anchorPoint location.


Concept 3: anti-aliasing
Anti-aliasing: in short, it is to soften the image so that the image edge looks smoother and closer to the object. In games, we sometimes perform operations such as enlarging or downgrading an image. In this case, an image without anti-aliasing is distorted or even distorted. I will use some images on the Internet to illustrate the following. After reading these images, I have a perceptual knowledge of anti-aliasing:

Because the image above does not use anti-aliasing, we will see that some objects have a sawtooth edge and are not smooth. The image below uses anti-aliasing, which looks more real and smooth.
However, it should be noted that, when using anti-sawtooth images, the burden on the processor will be capitalized, but the user experience will be better. You can use them as appropriate.
 

Related Article

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.