0
votes

Is it possible to get the current frame from the running Animation/action in cocos2d-x ? There is a function called iSDone but it will give me action done boolean once of the sprite and also will not provide the sprite data.

I want the height,width , x and y of the current frame while action is running.

is there any way ?

1
Seemingly there is no interface for you to do this.The only way is to modify or subclass the class 'CCAnimate',rewrite or override the function 'update()'PeakCoder
cocos2d-iphone has a CCSprite property displayFrame which returns the currently displayed CCSpriteFrame. Is there no equivalent for that in cocos2d-x?LearnCocos2D
@LearnCocos2D : displayFrame is there ... I guess i will work around with it and will let u know if this is the thing which i waantuser1169079

1 Answers

1
votes
int CCAnimationHelper::frameOfAnimation(cocos2d::CCAnimation *animation, cocos2d::CCSprite *sprite){
CCTexture2D* tex = sprite->getTexture();
int imageIndex = 0;
for (int i=0; i<animation->getFrames()->count(); i++) {
    CCAnimationFrame *frame = (CCAnimationFrame*)animation->getFrames()->objectAtIndex(i);
    CCTexture2D *tex2 = frame->getSpriteFrame()->getTexture();
    if (tex->isEqual(tex2)) {
        imageIndex = i;
        break;
    }
}


return imageIndex;
}