Coordinate systems in the Cocos2d-x

Source: Internet
Author: User

The coordinate system in the cocos2d-x is the Cartesian coordinate system, right is the x-axis positive direction, and up is the y-axis positive direction, in pixels

The coordinate system of the origin in the lower left corner of the screen is called the World coordinate system, which is the foundation of the whole game, which is added directly to the nodes in the scene, and the location is the world coordinate system, and the getPosition returns the world coordinate system.

Each node can be used as a coordinate system, the origin of the node coordinate system is located in the lower left corner of its content, when the node is added child nodes, the location of the child nodes, according to the parent node's coordinate system, when the parent node changes, the child nodes do the same change, that is, the child node relative to the parent node; Analyze a node coordinate be sure to find the parent node

Node nodes provide conversion functions for the world coordinate system and the node coordinate system:

    VEC2 converttonodespace (const vec2& worldpoint) const;    VEC2 converttoworldspace (const vec2& nodepoint) const;
Anchor Point
    virtual void Setanchorpoint (const vec2& anchorpoint);    Virtual const vec2& Getanchorpoint () const;

The anchor has a two-layer meaning, which is the location of the setting relative to the parent node, and the location of the anchor point is setposition set.

Relative to their own, the anchor point is the reference point of their own deformation, such as rotation, is to rotate by the center point, or the bottom left corner of the rotation? Rotate by Anchor Point

The value of the anchor point is between (0,0) ~ (total), the size of the reference size, is a proportional number; (0.5,0.5) is the middle, is also the default, you can arbitrarily change the anchor point, or even out of range, at least the effect on the benevolent see.

According to the first meaning of the anchor point, modify the anchor point can also be changed position, especially the small range, accurate modification, but will bring undesirable side effects, so do not take the dog to meddle with the mouse.

Coordinate systems in the Cocos2d-x

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.