(no.00003) iOS games simple robot projection game forming (10)

Source: Internet
Author: User

Open Arm.h and add a new method to its interface:

-(void)armShoot;

Next, implement this method in ARM.M:

-(void)armShoot{    CGPoint startPoint = [self convertToWorldSpace:ccp(05)];    CGPoint endPoint = [self convertToWorldSpace:ccp(205)];    [_mainScene shoot:startPoint to:endPoint];}

The method eventually calls the shoot method in Mainscene, before which Armshoot obtains the trajectory of the bullet. The trajectory is determined by the starting and ending points, because the trajectory of the bullet is determined by the physical engine, so the final actual shot is a parabola.

As mentioned in the previous arm rotation application Lidian weights in the center of the arm and the focus of the hand, as well, the trajectory of the bullet is also coincident with Arm's midline:

So when is the bullet fired? There are many options, such as creating a launch button on the screen and firing bullets when clicked.

Here's a simpler way: firing bullets at the end of a player's touch:

-(void)touchEnded:(CCTouch *)touch withEvent:(CCTouchEvent *)event{    [self armShoot];}

Do the same in the Armstatic class. Here is a bad example, because there are duplicate code. If you write a program that also has a variety of sins, then code duplication is a "capital offense"!

But the first sentence of "Innocence", because the cat is also reconstructed, although you do not necessarily see;)

Compile and run, the effect of the launch is as follows:

Please ignore the middle of those squares and baskets, don't worry! They're going to be on the way;)

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

(no.00003) iOS games simple robot projection game forming (10)

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.