Wednesday, May 23, 2012

Want to do Fruite Ninja like swipe on Sprite?

I am new in cocos2d iphone game development.



And now a days I am stucked at a point i want to do fruit ninja like swipe on a sprite and



want to perform a function after swipe at sprite.I done Googling but did not get solution.i need your kind help.
Thanks



 CCSprite *object=[CCSprite spriteWithFile:@"shield.png"];
[self addRecognizers:object];
[object setPosition:ccp(166,160)];
[self addChild:object];

//now function add recognizers
- (void) addRecognizers:(CCSprite*)node
{
UISwipeGestureRecognizer *swipeMe=[[[UISwipeGestureRecognizer alloc ]init] autorelease];
[swipeMe setDirection:UISwipeGestureRecognizerDirectionRight|UISwipeGestureRecognizerDirectionLeft|UISwipeGestureRecognizerDirectionUp|UISwipeGestureRecognizerDirectionDown];
recognizer = [CCGestureRecognizer CCRecognizerWithRecognizerTargetAction:swipeMe target:self action:@selector(blink:node:)];

[node addGestureRecognizer:recognizer];
}


This is the code i am using





No comments:

Post a Comment