私は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]]];
}
}