I have just started to looking at cocos2d and much interested to learn.
Basically i just want to draw a little solid circle (like a dot around 20 radius) where i touch the screen and it can only enable after pressing a button. How can i do this ?
For button i am using CCMenuItem
. This is the code.
-(id) init
{
CCMenuItem *enableBtn = [CCMenuItemImage itemFromNormalImage:@"refresh-icon.jpg" selectedImage:@"Button1.png" target:self selector:@selector(drawEnable:)];
enableBtn.position = ccp(10, 60);
enableBtn.scale = 0.1;
CCMenu *menu = [CCMenu menuWithItems:enableBtn, nil];
menu.position = ccp(30, 10);
[self addChild:menu];
}
- (void) drawEnable:(id)sender{
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
}
After tapping this button only , i want a circle where ever i touch on the screen.
Please help me in this. I have searched and tried many thing but not able to achieve the clear knowledge or idea about this thing.
Your suggestions are welcome.
Thank you ,
Here what you can do :
When the button is tapped set one boolean variable to true.
In touchesBegan method first check if that boolean variable is true, If it is then only insert the sprite/Dot or what ever you are willing to insert.
and then just set that boolean variable to false.