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)