(No. 00002) prototype of iOS game genie war (8)

Source: Internet
Author: User

(No. 00002) prototype of iOS game genie war (8)

The first two articles of the bullet initialization work are basically done. The following describes how to take a bullet.

Generally, when a bullet is directed to a target object, a straight line is taken. The line is located at two points, which are the emission point and the target point respectively.

The launch point is the position of the shooting genie, and the target point is the position of the enemy genie, as shown in:

According to the physics and mechanics principle of junior high school, to fly bullets along the orange path in the middle, you need to attach the (x, y) torque to the bullets. this is probably the meaning. Good kids shoes can be understood by themselves. I cannot save you because of poor physics ;)

Is the value of (x, y) to be found now? From this, we can find that x is exactly equal to the difference between x value of the red genie position and x value of the green genie position, and y value is the same, so we get: <Strong? Http: www.bkjia.com kf ware vc "target =" _ blank "class =" keylink "> Expires + DQo8cD7U2mNvY29zMmTW0Cy/ydLU08PE2tbDuq/K/cfhy8nKtc/wow.vcd4ncjxwcmugy2xhc3m9 "brush: java;"> CcpSub (greenSprite. position, redSprite. position );

Now that we know the principle of bullet launching, we will try to complete the code for bullet launching in the next article. For more information, see ;)

 

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.