29{
30}
1// objc with cocos2d-iphone
2// in init()
3// Initialize arrays
4_targets = [[NSMutableArray alloc] init];
5_projectiles = [[NSMutableArray alloc] init];
6
7- (void) dealloc
8{
9 [_targets release];
10 _targets = nil;
11
12 [_projectiles release];
13 _projectiles = nil;
14
15 // don't forget to call "super dealloc"
16 [super dealloc];
17}
现在可以修改
addTarget(),把新目标添加到目标数组中,并设置其 tag 为 1。
1// cpp with cocos2d-x
2// Add to targets array
3target->setTag(1);