我的场景中有 7 个精灵。所有精灵都添加到 mutablearray。当我触摸一个精灵移动时,其他精灵在我触摸移动方法后不可见
这是我的代码
if( (self=[super init])) {
sprites=[[NSMutableArray alloc]init];
CCLayer *base=[CCSprite spriteWithFile:@"Base.png"];
base.position=ccp(512,384);
[self addChild:base];
x=0;
for(int i=1;i<=7;i++)
{
CCSprite *hole=[CCSprite spriteWithFile:@"ball.png"];
hole.position=ccp(140+x,318);
hole.tag=i;
[self addChild:hole];
hole.visible=YES;
[sprites addObject:hole];
x=x+75;
}
self.isTouchEnabled=YES;
}
return self;
}
My touchesmove method:
-(void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"count:%i",[sprites count]);
UITouch *touch=[touches anyObject];
CGPoint location=[touch locationInView:[touch view]];
location=[[CCDirector sharedDirector]convertToGL:location];
location=[self convertToNodeSpace:location];
for(CCSprite *s in sprites)
{
s.position=ccp(location.x,location.y);
}
}