[Cocos2d-js tutorial] some common functions in cocos2d-js, cocos2d-js tutorial

Source: Internet
Author: User

[Cocos2d-js tutorial] some common functions in cocos2d-js, cocos2d-js tutorial

This article by qinning199 original, reproduced Please note: http://www.cocos2dx.net/post/223

1. cc. rectIntersectsRect (ra, rb) checks whether two rectangles are intersecting. If yes, true is returned.

Use Case:

Var rectA = cc. rect (0, 0, 5, 10 );

Var rectB = cc. rect (4, 9, 5, 10 );

Var r = cc. rectIntersectsRect (rectA, rectB );

If (! R) throw "Fail rectIntersectsRect 1 ";

2. cc. rectContainsPoint (rect, point) checks whether a rectangle contains a vertex. If so, true is returned.

3. cc. pointEqualToPoint (point1, point2) checks whether two vertices are equal and returns true if they are equal.

4. cc. rectEqualToRect (rect1, rect2) checks whether two rectangles are equal

5. cc. _ rectEqualToZero (rect) determines whether the rectangle is a 0 matrix.

6. cc. rectOverlapsRect (rectA, rectB) to determine whether the two rectangles partially overlap

7. cc. rectIntersection (rectA, rectB) returns the overlapping part of the two rectangles.

8. cc. rectUnion (rectA, rectB) returns the smallest rectangle containing the two rectangles.

 

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.