Ejemplo n.º 1
0
CCAnimate* Image::getFullAnimation(float delay, bool invert)
{
    CCAssert(spriteSheet != NULL, "Image getFullAnimation called on an object without spritesheet");
    CCArray* animationFrames = CCArray::createWithCapacity(spritesName->count());
    for(int i = 0; i < spritesName->count(); i++)
    {
        CCSpriteFrame* spriteFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(((CCString*)spritesName->objectAtIndex(invert ? spritesName->count() - i - 1 : i))->getCString());
        CCAnimationFrame* frame = new CCAnimationFrame();
        frame->initWithSpriteFrame(spriteFrame, 1, NULL);
        frame->autorelease();
        animationFrames->addObject(frame);
    }
    return CCAnimate::create(CCAnimation::create(animationFrames, delay));
}
Ejemplo n.º 2
0
void Image::runFullAnimation(float delay, bool invert)
{
    CCAssert(spriteSheet != NULL, "Image runFullAnimation called on an object without spritesheet");
    CCArray* animationFrames = CCArray::createWithCapacity(spritesName->count());
    for(int i = 0; i < spritesName->count(); i++)
    {
        CCSpriteFrame* spriteFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(((CCString*)spritesName->objectAtIndex(invert ? spritesName->count() - i - 1 : i))->getCString());
        CCAnimationFrame* frame = new CCAnimationFrame();
        frame->initWithSpriteFrame(spriteFrame, 1, NULL);
        frame->autorelease();
        animationFrames->addObject(frame);
    }
    CCAction* action = CCRepeatForever::create(CCAnimate::create(CCAnimation::create(animationFrames, delay)));
    if(runningAnimation != action)
    {
        if(runningAnimation != NULL)
        {
            delegate->stopAction(runningAnimation);
        }
        delegate->runAction(action);
        runningAnimation = action;
    }
}