我能够在运行时在 CCSprite 对象上调用这些方法,现在我决定在 CCSpriteBatchNode 中对其进行批处理,它似乎不再起作用了:
sprt = [CCSprite spriteWithSpriteFrameName:@"sprt.png"];
sprt.anchorPoint = CGPointMake(0.5f, 0.5f);
sprt.position = CGPointMake(40.0f, 60.0f);
[batchNode addChild:sprt z:-1]; // It used to work when I was simply "adding as child" the sprt object, I guess now doesn't set the order anymore because somehow the CCSpriteBatch node doesn't allow the re-ordering of child added to it
CCCallFunc *callback = [CCCallFunc actionWithTarget:self selector:@selector(moveBackwards)];
CCCallFunc *callback2 = [CCCallFunc actionWithTarget:self selector:@selector(moveForward)];
[sprt runAction: [CCRepeatForever actionWithAction: [CCSequence actions: callback2, callback , nil]]];
-(void) moveBackwards
{
[sprt setZOrder:-1];
}
-(void) moveForward
{
[sprt setZOrder:1];
}