I'm using a CCMenu
in my small project, it has three buttons in it. I need these buttons to keep triggering if they detect a touch, and as this isn't normal behaviour I decided to subclass the CCMenuItem
and override a couple of methods.
The two methods I wish to override are:
-(void) selected
{
// subclass to change the default action
if(isEnabled_) {
[super selected];
[self stopActionByTag:kZoomActionTag];
originalScale_ = self.scale;
CCAction *zoomAction = [CCScaleTo actionWithDuration:0.1f scale:originalScale_ * 1.2f];
zoomAction.tag = kZoomActionTag;
[self runAction:zoomAction];
}
}
-(void) unselected
{
// subclass to change the default action
if(isEnabled_) {
[super unselected];
[self stopActionByTag:kZoomActionTag];
CCAction *zoomAction = [CCScaleTo actionWithDuration:0.1f scale:originalScale_];
zoomAction.tag = kZoomActionTag;
[self runAction:zoomAction];
}
}
So in my subclass I am simply duplicating these exactly, but replace the code inside with the new functionality. To keep it simple, we'll say:
-(void) selected
{
//turn a sprite around
mySprite.rotation = 0;
}
-(void) unselected
{
//turn a sprite around
mySprite.rotation = 180;
}
Now, the mySprite would be declared in the header of the main body code, which gets imported into this subclass.
The problem is mySprite cannot be seen, it's getting an undeclared
error. Instead of mySprite
should I be using [super selected]
? I have tried this, I get the exact same error.
Thanks.