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

Source: Internet
Author: User

Back to Xcode, create a new Level1 class that inherits from Ccnode.

Open LEVEL1.M Add the following method to the initialization method:

-(void)didLoadFromCCB{    [self initBasket];    [self initRestrict];}

2 of these methods are implemented below respectively.

The first is initbasket:

-(void)initBasket{    *mov1 = [CCActionMoveBy actionWithDuration:5 position:ccp(0, -0.7)];    *mov2 = [CCActionMoveBy actionWithDuration:5 position:ccp(00.7)];    *seq = [CCActionSequence actions:mov1,mov2,nil];    *repeat = [CCActionRepeatForever actionWithAction:seq];    [_basket runAction:repeat];}

The simple thing is to move the basket with action and keep the movement forever.

Following is the Restrict method:

-(void)initRestrict{    LevelRestrict *lr = [LevelRestrict sharedInstance];    lr.bulletCount10;    lr.timeCount60;    lr.scoreCount3;}

Each level has a specific clearance conditions, class levelrestrict is used to save the condition of the class, wherein the Bulletcount,timecount and Scorecount respectively indicate the level of the bullet limit, time limit and fractional limit.

Create a new Levelrestrict class in Xcode, inherit from NSObject, and modify the LevelRestrict.h as follows:

#import <Foundation/Foundation.h>  @interface levelrestrict : nsobject @property(nonatomic,Assign)NsintegerBulletcount;@property(nonatomic,Assign)NsintegerTimecount;@property(nonatomic,Assign)NsintegerScorecount;@property(nonatomic,Strong)NSString*levelname;+ (instancetype) sharedinstance;-(void) Print;

Open LEVELRESTRICT.M to implement the Singleton method:

+(instancetype)sharedInstance{    static LevelRestrict *sharedLevelRestrict;    if (!sharedLevelRestrict) {        new];    }    return sharedLevelRestrict;}

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

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

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.