I'm developing a "starter" isometric game for iPhone using cocos2d. I decided to create my own "tiles system" because I've worked with isometric before (Flash), instead of using Tiled (tmx and so). The problem I've is re-calculating the zOrder while a sprite is moving. I know that, in order to change zOrder during an action, I have to add to the method -(void) update: (ccTime) t (in CCActionInterval.m) the code:
[[_target parent] reorderChild:_target z:depth];
This works. My problem comes when calculating the "depth", and here is why:
I've an object of type Player with a method that calculates the corresponding depth, so once I'm in CCActionInterval.m (where self is the CCSprite) I need to access the "parent" of "self", i.e., the parent of the CCSprite (which should be the object Player), so that I can do:
depth=[[self getParent] calculateDepth:(data)]
The question is: how to access the "parent" of this CCSprite?
PS: I know I can make Player to inherit from CCSprite and just use self, but I don't want to do it that way because in the future Player might have more than one CCSprite.