I have added a sprite and added a label as the child of the sprite.
Now I want to click the sprite and get the corresponding label text .Help me with some solution.
bubblesprite = [CCSprite spriteWithFile:#"bubble2.png"];
bubblesprite.position=CGPointFromString([self positioning]);
[self addChild:bubblesprite];
label = [CCLabelTTF labelWithString:[tempArray2 objectAtIndex:i] fontName:#"Marker Felt" fontSize:30];
label.color = ccc3(233,34,19);
[bubblesprite addChild: label z:1];
CGSize s = [bubblesprite contentSize];
label.position = ccp(s.width/2, s.height/2);
To access your labelstring use your tempArray2 [tempArray2 objectAtIndex:i]
I suggest to use CCMenu for your demand.
NSString* labelString = #"test";
CCLabelTTF* aLabel = [CCLabelTTF labelWithString:labelString fontName:#"Maker Felt" fontSize:24];
aLabel.position = ccp(100, 100);
[self addChild:aLabel];
CCMenuItemImage* button = [CCMenuItemImage itemFromNormalImage:#"Icon.png" selectedImage:#"Icon.png" target:self selector:#selector(buttonPress)];
button.position = ccp(100, 100);
CCMenu* menu = [CCMenu menuWithItems:button, nil];
menu.position = ccp(0, 0);
[self addChild:menu];
-(void)buttonPress
{
CCLog("%#", labelString);
}
To change the text from the label use its setText: method. This method is slow. For a fast version use CCLabelBMFont http://www.cocos2d-iphone.org/api-ref/0.99.5/interface_c_c_label_b_m_font.html
Related
I am a newbie to the world of cocos2d i am developing my first tutorial and facing one problem
my problem is i have an image (1024 X 320) and my orientation is landscape i need to move that image continuously from right to left for this purpose i have used space shooter tutorial by Ray(Thanks to him) but the image doesn't seem to be appearing again and again.
my code is..
-(id) init
{
if( (self=[super init])) {
CGSize screenSize = [CCDirector sharedDirector].winSize;
// 1) Create the CCParallaxNode
backgroundNode = [CCParallaxNode node];
[self addChild:backgroundNode z:-1];
// 2) Create the sprites we'll add to the CCParallaxNode
Back = [CCSprite spriteWithFile:#"bg_front_spacedust.png"];
//Back.position=ccp(screenSize.width/2, screenSize.height/2);
Back.rotation = -90;
Back1 = [CCSprite spriteWithFile:#"bg_front_spacedust.png"];
Back1.rotation = -90;
// 3) Determine relative movement speeds for space dust and background
CGPoint dustSpeed = ccp(0.1, 0.1);
// 4) Add children to CCParallaxNode
[backgroundNode addChild:Back z:0 parallaxRatio:dustSpeed positionOffset:ccp(screenSize.width/2, screenSize.height/2)];
NSLog(#"back.content width is...%f",Back.contentSize.width);
[backgroundNode addChild:Back1 z:1 parallaxRatio:dustSpeed positionOffset:ccp(screenSize.width/2, screenSize.height*2)];
// 5) Enable updates
[self scheduleUpdate];
}
return self;
}
- (void)update:(ccTime)dt {
// 1) Update background position
CGPoint backgroundScrollVel = ccp(0,-1000);
backgroundNode.position = ccpAdd(backgroundNode.position, ccpMult(backgroundScrollVel, dt));
// 2) Check for background elements moving offscreen
NSArray *spaceDusts = [NSArray arrayWithObjects:Back, Back1, nil];
for (CCSprite *spaceDust in spaceDusts) {
if ([backgroundNode convertToWorldSpace:spaceDust.position].x < -spaceDust.contentSize.width) {
[backgroundNode incrementOffset:ccp(2*spaceDust.contentSize.width,0) forChild:spaceDust];
}
}
}
please help me out of this
Thanks in advance.
try this one
if (backgroundNode.position.y <-screenSize.height*2)
backgroundNode.position = ccp(0,0);
As init method is called only once the approach you are doing will be done only one time you need to again set the Position of the backgroundNode to 0 in your update method.
here the multiple may vary
Try this code it is creating a paralax moving from bottom to top change CGPointMake(0, 1.0) to this CGPointMake(1.0,0) in paraNode addChild line.
-(id) init
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super's" return value
if( (self=[super init]) )
{
float yPos =0.0;
NSMutableString *fileNameString = [[NSMutableString alloc]initWithCapacity:0];
if (IS_IPHONE_5)
{
[fileNameString appendString:#"Background-568h.png"];
yPos= 560.0;
}
else
{
[fileNameString appendString:#"Background.png"];
yPos= 470.0;
}
background1 = [CCSprite spriteWithFile:fileNameString];
background1.tag = 1;
background1.anchorPoint = CGPointMake(0,0);
background2 = [CCSprite spriteWithFile:fileNameString];
background2.tag = 2;
background2.anchorPoint = CGPointMake(0,0);
background3 = [CCSprite spriteWithFile:fileNameString];
background3.tag = 3;
background3.anchorPoint = CGPointMake(0,0);
background4 = [CCSprite spriteWithFile:fileNameString];
background4.tag = 4;
background4.anchorPoint = CGPointMake(0,0);
paraNode = [CCParallaxNode node];
[paraNode addChild:background1 z:1 parallaxRatio:CGPointMake(0, 1.0) positionOffset:CGPointMake(0, 0)];
[paraNode addChild:background2 z:2 parallaxRatio:CGPointMake(0, 1.0) positionOffset:CGPointMake(0, -yPos)];
[paraNode addChild:background3 z:3 parallaxRatio:CGPointMake(0, 1.0) positionOffset:CGPointMake(0, -yPos*2)];
[paraNode addChild:background4 z:4 parallaxRatio:CGPointMake(0, 1.0) positionOffset:CGPointMake(0, -yPos*3)];
[self addChild:paraNode z:-1 tag:123];
[self updateFrameRate:0.7 andYposition:yPos];
[fileNameString release];
fileNameString = nil;
}
return self;
}
-(void)updateFrameRate:(float)speedValue andYposition:(float)yposToSet
{
move1 = [CCMoveBy actionWithDuration:speedValue position:CGPointMake(0, yposToSet)];
move2 = [CCMoveBy actionWithDuration:0.0 position:CGPointMake(0, -yposToSet)];
move3 = [CCMoveBy actionWithDuration:0.0 position:CGPointMake(0, 0)];
CCSequence* sequence = [CCSequence actions:move1,move2,move3, nil];
CCRepeatForever* repeat = [CCRepeatForever actionWithAction:sequence];
[paraNode runAction:repeat];
}
I used cocos2d game tutorial from http://www.raywenderlich.com/25736/how-to-make-a-simple-iphone-game-with-cocos2d-2-x-tutorial After i add the score to scorelabel, the score increases but the previous score isn't getting removed and the new score gets added above the earlier score's label
code:
CGSize winSize = [[CCDirector sharedDirector] winSize];
CCLabelTTF * label1 = [CCLabelTTF labelWithString:#"_monsterdestroyed" fontName:#"Arial" fontSize:32];
score=score + 2;
[label1 setString:[NSString stringWithFormat:#"%d",score]];
label1.color = ccc3(0,0,0);
label1.position = ccp(winSize.width/2, winSize.height/2);
[self addChild:label1];
I am guessing that you are doing all this in an update method, adding a label1 label at every update. You probably want an iVar in your .h file for the score label1 , initialize it in your init, as follows:
in .h
CCLabelTTF *label1;
in .m
-(id) init {
if (self = [super init]) {
// your existing code, add the following
CGSize winSize = [[CCDirector sharedDirector] winSize];
label1 = [CCLabelTTF labelWithString:#"0" fontName:#"Arial" fontSize:32];
label1.color = ccc3(0,0,0);
label1.position = ccp(winSize.width/2, winSize.height/2);
[self addChild:label1];
}
}
// where you update the score
score = score + 2;
[label1 setSting:[NSString stringWithFormat:"%i", score];
Just had a small question. I'm trying to make a UIButton appear programmatically, which I have to animate. But once the animation gets done, I can't click the button for some reason.
I have a CALayer "animationLayer" as a sublayer of the UIView, and within that animationLayer, I have three CAShapeLayers "pathLayers" (which I use to animate three different path ways as you can see in the diagram below). And within those pathLayers, I'm adding three buttons as their respective sublayers so that I can have an animation where the buttons move along the path as the path draws itself. Everything was working good until I tried adding a button as a sublayer of the pathLayer. Now when I click on the button, it's supposed to go to a method that logs on the console window "Button has been pressed". I've tried setting the self.view.userInteractionenabled to YES but that still gives me nothing.
Why I can't click it?
Here's some relevant parts of the code:
- (void)viewDidLoad
{
[super viewDidLoad];
self.animationLayer = [CALayer layer];
self.animationLayer.frame = CGRectMake(20.0f, 64.0f,
CGRectGetWidth(self.view.layer.bounds) - 40.0f, CGRectGetHeight(self.view.layer.bounds) - 84.0f);
[self.view.layer addSublayer:self.animationLayer];
}
- (id)createUIButtonwithXPosition:(CGFloat)x YPosition:(CGFloat)y Width:(CGFloat)width Height:(CGFloat)height
{
UIImage *lionImage = [UIImage imageNamed:#"noun_project_347_2.png"];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self
action:#selector(logger:)
forControlEvents:UIControlEventTouchUpInside];
button.frame = CGRectMake(x, y, width, height);
button.userInteractionEnabled = YES;
// [button setBackgroundColor:[UIColor clearColor]];
[button setBackgroundImage:lionImage forState:UIControlStateNormal];
[self.view addSubview:button];
return button;
}
- (void)setupDrawingLayer
{
if(self.pathLayer != nil){
[self.pathLayer removeFromSuperlayer];
[self.secondPathLayer removeFromSuperlayer];
[self.thirdPathLayer removeFromSuperlayer];
self.pathLayer = nil;
self.secondPathLayer = nil;
self.thirdPathLayer = nil;
...//Other code not relevant
}
CGRect pathRect = CGRectInset(self.animationLayer.bounds, 100.0f, 100.0f);
CGPoint bottomCenter = CGPointMake(CGRectGetMidX(pathRect), (self.lionBtnVerticalAlignment.constant + self.lionBtnHeight.constant + 25.0f));
CGPoint center = CGPointMake(CGRectGetMidX(pathRect), CGRectGetMidY(pathRect));
CGPoint leftCenter = CGPointMake(CGRectGetMinX(pathRect), CGRectGetMidY(pathRect));
CGPoint rightCenter = CGPointMake(CGRectGetMaxX(pathRect), CGRectGetMidY(pathRect));
UIBezierPath *path = [UIBezierPath bezierPath];
UIBezierPath *secondPath = [UIBezierPath bezierPath];
UIBezierPath *thirdPath = [UIBezierPath bezierPath];
[path moveToPoint:bottomCenter];
[path addLineToPoint:center];
[secondPath moveToPoint:bottomCenter];
[secondPath addLineToPoint:leftCenter];
[thirdPath moveToPoint:bottomCenter];
[thirdPath addLineToPoint:rightCenter];
CAShapeLayer *pathLayer = [CAShapeLayer layer];
pathLayer.frame = self.animationLayer.bounds;
pathLayer.bounds = pathRect;
pathLayer.geometryFlipped = YES;
pathLayer.path = path.CGPath;
pathLayer.strokeColor = [UIColor blackColor].CGColor;
pathLayer.fillColor = nil;
pathLayer.lineWidth = 3.0f;
pathLayer.lineDashPattern = [NSArray arrayWithObjects:
[NSNumber numberWithInt:6],
[NSNumber numberWithInt:2],
nil];
pathLayer.lineJoin = kCALineJoinBevel;
CAShapeLayer *secondPathLayer = [CAShapeLayer layer];
secondPathLayer.frame = self.animationLayer.bounds;
secondPathLayer.bounds = pathRect;
secondPathLayer.geometryFlipped = YES;
secondPathLayer.path = secondPath.CGPath;
secondPathLayer.strokeColor = [UIColor redColor].CGColor;
secondPathLayer.fillColor = nil;
secondPathLayer.lineWidth = 3.0f;
secondPathLayer.lineDashPattern = [NSArray arrayWithObjects:
[NSNumber numberWithInt:6],
[NSNumber numberWithInt:2],
nil];
secondPathLayer.lineJoin = kCALineJoinBevel;
CAShapeLayer *thirdPathLayer = [CAShapeLayer layer];
thirdPathLayer.frame = self.animationLayer.bounds;
thirdPathLayer.bounds = pathRect;
thirdPathLayer.geometryFlipped = YES;
thirdPathLayer.path = thirdPath.CGPath;
thirdPathLayer.strokeColor = [UIColor greenColor].CGColor;
thirdPathLayer.fillColor = nil;
thirdPathLayer.lineWidth = 3.0f;
thirdPathLayer.lineDashPattern = [NSArray arrayWithObjects:
[NSNumber numberWithInt:6],
[NSNumber numberWithInt:2],
nil];
thirdPathLayer.lineJoin = kCALineJoinBevel;
[self.animationLayer addSublayer:pathLayer];
[self.animationLayer addSublayer:secondPathLayer];
[self.animationLayer addSublayer:thirdPathLayer];
self.pathLayer = pathLayer;
self.secondPathLayer = secondPathLayer;
self.thirdPathLayer = thirdPathLayer;
UIImage *lionImage = [UIImage imageNamed:#"noun_project_347_2.png"];
btn1 = (UIButton *)[self createUIButtonwithXPosition:0.0f YPosition:0.0f Width:lionImage.size.width Height:lionImage.size.height];
btn1.layer.anchorPoint = CGPointZero;
btn1.layer.frame = CGRectMake(0.0f, 0.0f, lionImage.size.width, lionImage.size.height);
[self.view bringSubviewToFront:btn1];
self.view.userInteractionEnabled = YES;
....//Other code not relevant
}
- (void)startAnimation
{
[self.pathLayer removeAllAnimations];
[self.secondPathLayer removeAllAnimations];
[self.thirdPathLayer removeAllAnimations];
....//Other code not relevant
CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:#"strokeEnd"];
pathAnimation.duration = 3.0;
pathAnimation.fromValue = [NSNumber numberWithFloat:0.0f];
pathAnimation.toValue = [NSNumber numberWithFloat:1.0f];
[self.pathLayer addAnimation:pathAnimation forKey:#"strokeEnd"];
[self.secondPathLayer addAnimation:pathAnimation forKey:#"strokeEnd"];
[self.thirdPathLayer addAnimation:pathAnimation forKey:#"strokeEnd"];
CAKeyframeAnimation *lionAnimation = [CAKeyframeAnimation animationWithKeyPath:#"position"];
lionAnimation.duration=3.0;
lionAnimation.path = self.pathLayer.path;
lionAnimation.calculationMode = kCAAnimationPaced;
lionAnimation.delegate = self;
[btn1.layer addAnimation:lionAnimation forKey:#"position"];
btn1.layer.position = CGPointMake(365.0, 460.0);
}
Seems to me that you might be experiencing a typical problem in which a UIView is a sub child of another UIView, but outside of its bounds. To check whether this is the case, set the property of the parentview to setClipsToBounds:YES and you will most likely see the button disappear. Check this post for additional details: My custom UIView dos not receive touches
If this is the case you have a couple of options.
Place the button in a place where it is within the bounds of the parent view!!
Subclass the parent view and add the following code to is so that its subviews may respond to touches even when they are outside the bounds of the parent view.
-(UIView *) hitTest:(CGPoint)point withEvent:(UIEvent *)event{
UIView* result = [super hitTest:point withEvent:event];
if (result)
return result;
for (UIView* sub in [self.subviews reverseObjectEnumerator]) {
CGPoint pt = [self convertPoint:point toView:sub];
result = [sub hitTest:pt withEvent:event];
if (result)
return result;
}
return nil;
}
Please try this:
[button setBackgroundImage:lionImage forState:UIControlEventTouchUpInside];
I've a problem when I try to show the final score in the Game Over Layer in a game in cocos2d. There's an algorithm that modify the value of my variable increment, that contains the points of the user and then the game shows them.
increment = increment + 50;
[pointLabel setString: [NSString stringWithFormat: #"Points: %i", increment]];
and then a function controls if the user has or not lives in his play
-(void)gameOver:(int)value punteggio:(id)punti{
if (value == 1) {
//WIN
}else if(value == 2){
if (life > 1) { // 1
life = life - 1;
for (CCSprite *spr in spriteLifeArray) {
if (life == spr.tag) {
[self removeChild:spr cleanup:YES];
}}}
else {
// LOSE
[...]
[[CCDirector sharedDirector] replaceScene:[GameOver node]];
}
}}
Then the GameOverLayer is called. This is the .h file
#interface GameOver : CCNode {
CGSize size;
CCLabelTTF *label1;
CCLabelTTF *label2;
CCLabelTTF *labelpnt;
CCLabelTTF *labelscore;
}
-(void)restart;
Here the .m file
#implementation GameOver
+(id) scene {
// 'scene' is an autorelease object.
CCScene *scene = [CCScene node];
// 'layer' is an autorelease object.
GameOver *layer = [GameOver node];
// add layer as a child to scene
[scene addChild: layer];
// return the scene
return scene;
}
-(id) init{
if( (self=[super init] )) {
size = [[CCDirector sharedDirector] winSize];
label1 = [CCLabelTTF labelWithString:#"Game Over" fontName:#"Marker Felt" fontSize:40];
label1.position = ccp(size.width/2 , size.height/2+20+50 );
labelpnt = [CCLabelTTF labelWithString:#"Punteggio" fontName:#"Marker Felt" fontSize:20];
labelpnt.position = ccp(size.width/2 , size.height/2+50-100 );
labelscore = [CCLabelTTF labelWithString:#"100" fontName:#"Marker Felt" fontSize:20];
[labelscore setString: [NSString stringWithFormat: #" 0 "]];
[labelscore setColor:ccc3(255, 1, 1)];
labelscore.position = ccp(size.width / 2, size.height/2+50-130);
label2 = [CCLabelTTF labelWithString:#"Ricomincia" fontName:#"Marker Felt" fontSize:25];
CCMenuItemLabel *back = [CCMenuItemLabel itemWithLabel:label2 target:self selector:#selector(restart)];
CCMenu *menu= [CCMenu menuWithItems:back, nil];
menu.position = ccp(size.width/2 , size.height/2-50+50);
[self addChild: label1];
[self addChild: labelpnt];
[self addChild: labelscore];
[self addChild: menu];
}
return self;
}
-(void) restart {
[[CCDirector sharedDirector] replaceScene:[HelloWorldLayer node]];
}
How can I show the final value of my int increment in the game over layer? How can I pass it throught the classes?
Use UserDefault. Here is code
//Save score in game screen
int highScore = 234;
[[NSUserDefaults standardUserDefaults] setInteger:12 forKey:#"HighScore"];
[[NSUserDefaults standardUserDefaults] synchronize];
//get score in game over
int highScore = [[NSUserDefaults standardUserDefaults] integerForKey:#"HighScore"];
NSString *score = [NSString stringWithFormat: #"%d", highScore];
CCLabelTTF *scoreLabel = [CCLabelTTF labelWithString:score fontName:#"Marker Felt" fontSize:40];
Hey in that Case You should take a separate layer for displaying the Score lives or whatever you want to display simultaneously.
In HUD Layer i.e Heads-Up Display class You should write some basic code to display a CCLabelBMFont to the screen that says "Your Score", “You Win” or “You Lose” and a button underneath that says “Restart”.
When the restart button is tapped, it creates a new instance of the ActionLayer switches to it.
Write a Score method scoreUpdate, this method will have the logic for the score calculation like whenever a bullet hit to monster and update it to the CCLabelBMFont label.
And then All you need to do just call that method.
Here is the one of the best tutorial for such requirement.
See
I am trying to simulate a modal view in cocos2d by displaying a few sprites over my scene and showing a menuitemsprite as a continue button. In the code below, i show my game over modal and have the menu set up with a CCMenuItemSprite; which does not respond to touches, and a CCMenuItemImage; which does work.
-(void) gameOver {
CGSize size = [[CCDirector sharedDirector] winSize];
self.menu.isTouchEnabled = NO;
CCLayer *modalLayer = [[CCLayer alloc] init];
[self addChild:modalLayer z:20];
CCSprite *spriteGameOver = [CCSprite spriteWithFile:#"game_over.png"];
spriteGameOver.position = ccp( size.width/2,size.height/2);
CCLabelTTF *lblGameOver = [CCLabelTTF labelWithString:[NSString stringWithFormat:#"Game Over!\nScore %d/%d",numCorrect,questionIdx] dimensions:CGSizeMake(380, 300) alignment:CCTextAlignmentCenter fontName:#"Trebuchet MS" fontSize:50.0f];
// position the label on the center of the screen
lblGameOver.position = ccp(size.width/2-200, size.height/2-100);
lblGameOver.color = ccc3(20, 20, 20);
lblGameOver.opacity = 0;
// add the label as a child to this Layer
[spriteGameOver addChild: lblGameOver];
spriteGameOver.opacity = 0;
[modalLayer addChild:spriteGameOver];
CCSprite *spriteGameOverBtn = [CCSprite spriteWithFile:#"mainButton.png" rect:CGRectMake(0,0,300,60)];
spriteGameOverBtn.position = ccp( size.width/2,size.height/2-100);
CCLabelTTF *lblGameOverBtn = [CCLabelTTF labelWithString:#"Continue" dimensions:CGSizeMake(300, 60) alignment:CCTextAlignmentCenter fontName:#"Trebuchet MS" fontSize:40.0f];
//lblGameOverBtn.position = ccp(size.width/2-200, size.height/2-300);
[lblGameOverBtn setAnchorPoint:ccp(0.0f,0.1f)];
lblGameOverBtn.color = ccc3(20, 20, 20);
lblGameOverBtn.opacity = 0;
// add the label as a child to this Layer
[spriteGameOverBtn addChild: lblGameOverBtn];
spriteGameOverBtn.opacity = 0;
CCMenuItemImage *itemH = [CCMenuItemImage itemFromNormalImage:#"backArrow.png" selectedImage:#"backArrowS.png" target:self selector:#selector(goToMain:)];
itemH.position = ccp( size.width/2,size.height/2-100);
CCMenuItemSprite *mGameOverBtn = [CCMenuItemSprite itemFromNormalSprite:spriteGameOverBtn selectedSprite:nil disabledSprite:nil target:self selector:#selector(goToMain:)];
CCMenu *menuGO = [CCMenu menuWithItems: itemH,mGameOverBtn, nil];
menuGO.position = ccp( 0, 0);
[modalLayer addChild:menuGO z:21];
[lblGameOverBtn runAction:[CCSequence actions:[CCDelayTime actionWithDuration: 1.75f],[CCFadeIn actionWithDuration: 1.75f],nil]];
[spriteGameOverBtn runAction:[CCSequence actions:[CCDelayTime actionWithDuration: 1.75f],[CCFadeIn actionWithDuration: 1.75f],[CCDelayTime actionWithDuration: 3.75f],nil]];
[lblGameOver runAction:[CCSequence actions:[CCDelayTime actionWithDuration: 1.75f],[CCFadeIn actionWithDuration: 1.75f],[CCDelayTime actionWithDuration: 3.75f],nil]];
[spriteGameOver runAction:[CCSequence actions:[CCDelayTime actionWithDuration: 1.75f],[CCFadeIn actionWithDuration: 1.75f],[CCDelayTime actionWithDuration: 3.75f],nil]];
//[self runAction:[CCSequence actions:[CCDelayTime actionWithDuration: 2.75f],[CCCallFunc actionWithTarget:self selector:#selector(goToMain:)], nil]];
}
I'm having the same problem with CCMenuItemSprite too. It looks like the CCMenuItemSprite-class is a bit buggy. In my case it doesn't respond to touches. But I found out it has something to do with multi-layered Sprites inside the CCMenuItemSprite. So when I use a single-layered Sprite it works, but when I use a Sprite which contains multiple embedded sprites it doesn't.
My 'not-ready-yet' solution right now is setting the contentSize to the appropriate size of the CCMenuItemSprite right after it has been initialized:
CCMenuItemSprite * menuItem = [CCMenuItemSprite itemWithNormalSprite:multiLayeredSprite selectedSprite:nil target:self selector:#selector(clickHandler:)];
[s setContentSize:backgroundSprite.contentSize];
CCMenu * menu = [CCMenu menuWithItems:
menuItem,
nil];
It's receiving touch-events now. The only problem I now have is the positioning of the Rectangle... it's still in the upper-right corner. I'll try to found out how to fix this now.
Hopefully this is clarifying a bit of the problem.
Have you have registered your scene with the touch dispatcher and your selectors actually do something?
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:NO]