(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 ;)