Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 12th, 2012  |  syntax: None  |  size: 1.29 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Accessing getter methods
  2. #import "cocos2d.h"
  3. #import "Box2D.h"
  4. #import "GLES-Render.h"
  5. #import <Foundation/Foundation.h>
  6.  
  7.  
  8. @class UILayer;
  9. @class Insect;
  10.  
  11. @interface GamePlayLayer : CCLayer {
  12.  
  13. b2World * world;
  14. GLESDebugDraw * debugDraw;
  15. CCSpriteBatchNode * sceneSpriteBatchNode;
  16. Insect * insect;
  17. b2Body *body;
  18. SceneUILayer * uiLayer;
  19.     double startTime;
  20. bool gameOver;
  21. bool gameWon;
  22. NSMutableArray *lives;
  23.  
  24. }
  25.  
  26. - (id)initWithUILayer:(UILayer *)sceneUILayer;
  27.  
  28.  
  29. @end
  30.        
  31. UILayer * sr = (UILayer *)[self.parent getChildByTag:10];
  32. CCSprite * live = [sr.lives objectAtIndex:self.lives];
  33. [live setVisible:NO];
  34.        
  35. @interface UILayer : CCLayer {
  36.  
  37. NSMutableArray *lives;
  38.  
  39.    }
  40.  
  41.  @property (nonatomic,retain) NSMutableArray *lives;
  42.        
  43. #import "UILayer.h"
  44. #import "GameManager.h"
  45.  
  46.  
  47. @implementation UILayer
  48.  
  49.  
  50. @synthesize lives;
  51.  
  52.     - (id)init {
  53.         if ((self = [super init])) {
  54.  
  55.  
  56.     lives = [[NSMutableArray arrayWithCapacity:3]retain];
  57.  
  58.     for(int i=0;i<3;i++)
  59.     {
  60.         CCSprite * life = [CCSprite spriteWithFile:@"life_Label.png"];
  61.         [life setPosition:ccp(winSize.width/18+ 32*i,290)];
  62.         [self addChild:life];
  63.         [lives addObject:life];
  64.     }
  65.    }
  66.        
  67. @interface blah
  68.  
  69. // ...
  70.  
  71. @property (assign) NSInteger lives;
  72.  
  73. @end
  74.        
  75. @implementation blah
  76.  
  77. @synthesize lives = _lives;
  78.  
  79. //your code
  80.  
  81. @end