CCARRAY_FOREACH cast problem

i have an animation and it loaded correctly before,
but now i want to modify every frame, in that case, i change their texture

@
CCAnimation* animation;
CCObject* object;
CCARRAY_FOREACH(animation->getFrames(),object)
{
    CCSpriteFrame* frame = static_cast(object);
    if(frame->getRect().size.width == 0 || frame->getRect().size.height == 0)
    {
        int a = 1;// i put break point here and see frame are corrupt
    }
    frame->setTexture(mTexture);
}
@

i put break point and see frame are corrupt, all of it’s value return to default(not the value i load)
i put “animation~~>retain;" and "frame~~>retain()”, everything retain, but it’s not works.

when i create a sprite and test “animation”, convert it into CCAction, let sprite run the action and it works. so i think the error there because i cast “CCSpriteFrame* frame = static_cast<CCSpriteFrame*>(object);”

can you cast with:
CCSpriteFrame* frame = (CCSpriteFrame*)object;

daniel fountain wrote:

can you cast with:
CCSpriteFrame* frame = (CCSpriteFrame*)object;

i tryed but not works

Try this:

     CCAnimation* animation;
     CCObject* object;
     CCARRAY_FOREACH(animation->getFrames(),object) {
          CCAnimationFrame* aniFrame = (CCAnimationFrame*)object;
          CCSpriteFrame* frame = aniFrame->getSpriteFrame();
          if(frame->getRect().size.width 0 || frame->getRect().size.height 0) {
               int a = 1;// :-)
          }
          frame->setTexture(mTexture);
     }

thank you all, it’s works :slight_smile: