I have made a simple physics sprite that will automatically trigger update selector and move the sprite accordingly to the b2body member set.
However when I do subclass that physics sprite, I want to extend that update method to do some more actions. When I do override that update method I somehow need to call the super classes update method so it can do its business before I do my business in the subclass.
Here is some code:
Superclass:
/**
* SELECTOR
* This selector updates the sprites position
*/
-(void) update:(ccTime) dt {
CCLOG(@"PSprite update");
if (self.body) {
//Get the body's position in pixels
CGPoint newLocationForSprite = ccp(self.body->GetPosition().x * PTM_RATIO, self.body->GetPosition().y * PTM_RATIO);
//positioning self
[self setPosition:newLocationForSprite];
}
}
Subclass:
-(void) update:(ccTime) dt {
//I want to call my superclass's update method
CCLOG(@"Subclass update");
}
subclass code