Simple solutions for cocos2dx archery and other throwing objects

Source: Internet
Author: User
It also seems from the Internet that the principle here is to use the rotation of the beiser curve bow and arrow to produce the parabolic effect of the bow and arrow. Besell curve: ccbezierconfigbezr; bezr. controlPoint_1start; bezr. controlPoint_2ccp (start. x + (end. x-start.x) * 0.5, start. y + (end. y-start.y) * 0.5 + 100)

It also seems from the Internet that the principle here is to use the rotation of the beiser curve bow and arrow to produce the parabolic effect of the bow and arrow. Besell curve: ccBezierConfig besuppliers; besuppliers. controlPoint_1 = start; bezr. controlPoint_2 = ccp (start. x + (end. x-start.x) * 0.5, start. y + (end. y-start.y) * 0.5 + 100)

It also looks like it on the Internet. Record it here

The principle is to use the beiser curve + the rotation of the bow and arrow to produce the parabolic effect of the bow and arrow.

Betel curve:

ccBezierConfig bezier;bezier.controlPoint_1 = start;bezier.controlPoint_2 = ccp(start.x+(end.x-start.x)*0.5,start.y+(end.y-start.y)*0.5+100);bezier.endPosition = ccp(end.x, end.y);float duration = 1.0f;CCBezierTo *actionBezier = CCBezierTo::create(duration,bezier);

ControlPoint_1 is the starting point, endPosition is the ending point of the beiser curve animation, and the most important controlPoint_2 is the trend of the curve, which determines the highest point of the curve. If you want to learn more about the beiser curve, please refer to here: http://www.jasondavies.com/animated-bezier/

Then there is the rotation Animation:

float angle = 45.0f;CCRotateTo *actionRotate =CCRotateTo::create(duration,angle);


Finally, let the two animations play simultaneously:
CCSpawn* actionSpawn = CCSpawn::createWithTwoActions(actionBezier,actionRotate);

All right, all done.

However, after doing so, I feel that the archery effect is still unsatisfactory. After all, it is a opportunistic method. To optimize the visual effect, you can adjust the animation playback speed.

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.