Boundary for sprites in cocos2d? -
On my screen I have different sprites and they are following after their target. It all works well
My question is, what is the way to set boundaries? I do not want them to take 160 points on the screen?
I see that every example is always using box 2D, is there a way to do it strictly with cocos2d? Am I receiving this error? - [__ NSRRMM status]: 0x84597b0 sent to unrecognized selector for example What I want to do is at the street stop at 160 and that is for examination method of examination. Just sets its position to 160. What do you want them to do when they reach their threshold? You can simply check them in a scheduled update method. You can run anywhere in your init This will call the update method in every frame. For your updated question, you can - (zero) adplayer {winSize = [CCDCD shared director] .Vinos; _officer = [[Officer Alok] initWithLayer: Self]; _officer.position = CCP (winSize.width / 2, 40); _officer.tag = 1; [_batchNode addChild: _officer]; _shotCaller = [[Shot Caller Alok] Init Withstand: 2nd Layer: Self]; // Make spawn point _shotCaller.position = CCP (100, 100); [_batchNode addChild: _shotCaller]; NSString * gunName = [NSString stringWithFormat: @ "gun page"]; _gun = [CCS light spread with asprintFrame name: gunname]; _gun.anchorPoint = CCP (0.5, 0.25); _gun.position = CCP (_shotCaller.contentSize.width / 2, _shotCaller.contentSize.height / 2 - 20); [_shotCaller addChild: _gun]; [Self Positioning: _shotCaller]; NSMutableArray * team1GameObjects = [NSMutableArray arrayWithObject: _officer]; NSMutableArray * team2GameObjects = [NSMutableArray arrayWithObject: _shotCaller]; _gameObjects = [NSMutableArray arrayWithObjects: team1GameObjects, team2GameObjects, zero]; } (_GameObjects in CCSprite * myGode) {if (myNode.position.y == 160) {NSLog (@ "1"); [Self check]}}
[auto scheduling: @selector (updated :));
- (zero) update: (ccTime) dt {for (self.arrayOfSpritesToCheck in CCSprite * s) {If (s.position.y> 160) {// do something} }}
NSMutableArray . Your Game Object array is the array of array when you do
(_NameMyNode * in _GameObjects) , it does not guarantee that the incoming objects will be CCNode and in fact your case will be
NSMutableArray s
Comments
Post a Comment