我是 Cocos2D 的初学者。我想在特定的 CCSprite 上添加手势,但我在 CCLayer 上有手势。我的要求是在 CCSprite 上添加手势。这个怎么做?
我的代码:
-(id) initWithMask
{
CCSprite *mask=[CCSprite spriteWithFile:@"circle_mask.png"];
[self addChild:moveGlopFront z:1];
UISwipeGestureRecognizer *swipeGestureRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handlePushSceneGestureRecognizer:)];
[self addGestureRecognizer:swipeGestureRecognizer];
swipeGestureRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
swipeGestureRecognizer.delegate = self;
}
-(void)handlePushSceneGestureRecognizer:(UISwipeGestureRecognizer*)aGestureRecognizer
{
for(CCNode *child in layer.children)
{
[child stopAllActions];
}
for(CCNode *child in layer.children)
{
[moveGlopFront setTexture:[moveGlopBack texture]];
[moveGlopFront runAction:[CCRepeatForever actionWithAction:[CCRotateBy actionWithDuration:5.0 angle:360]]];
}
}