"Turn" achieves fruit Ninja's knife-light effect

Source: Internet
Author: User

Implementation ideas:
√ from multi-touch to get across the trajectory, the number of control points, the general use of queues, new points to extrude the point of the end of the team. This is expressed as point[16];

√ Cycle; Point and point[i+1] form the line L, calculate the slope of the line, the angle θ from the slope (can review the polar coordinates), so as to get the normal equation of L (xcosθ+ysinθ-p=0);
With width W (-W), the point is shifted along the normal direction, resulting in a trajectory of 2 translations.
Here the absolute value of W, the head should be wider, the tail contraction to 0.


The key algorithm, the expert will see a joke.

1 Cgpoint pt = ccpsub (p1, p2); 2 glfloat angle = ccptoangle (PT); 3  4 glfloat x = sinf (angle) * W; 5 glfloat y = COSF (angle) * W; 6 vertex->x = p1.x+x; 7 vertex->y = p1.y-y;

Attachment address:

"Turn" achieves fruit Ninja's knife-light effect

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.