Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8510355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:40:53+00:00 2026-06-11T03:40:53+00:00

I am trying to play through an animation using these files that I created

  • 0

I am trying to play through an animation using these files that I created with texture packer (footballAnim-hd.pvr.ccz) and (footballAnim.pv-hd.plist) but I have encountered a problem. Here is my code:

[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"footballAnim.pv.plist"];

    CCSprite *football = [CCSprite spriteWithSpriteFrameName:@"Football59-hd.png"];
    football.position = ccp(100, 100);

    CCSprite *football2 = [CCSprite spriteWithSpriteFrameName:@"Football59-hd.png"];
    football2.position = ccp(120, 100);

    //This is the animation
    id anim = [CCAnimate actionWithSpriteSequence:@"Football%d-hd.png"
                                                  numFrames:59
                                                      delay:0.01
                                       restoreOriginalFrame:NO];
    //This is the animation
    id anim2 = [CCAnimate actionWithSpriteSequence:@"Football%d-hd.png"
                                        numFrames:59
                                            delay:0.01
                             restoreOriginalFrame:NO];

    //This is the action
    id repeat = [CCRepeatForever actionWithAction:anim];

    //This is the action
    id repeat2 = [CCRepeatForever actionWithAction:anim2];

     CCSpriteBatchNode *batchNode=[CCSpriteBatchNode batchNodeWithFile:@"footballAnim.pvr.ccz"];
    [self addChild:batchNode];
    [batchNode addChild:football];
    [batchNode addChild:football2];

    [football runAction:repeat];
    [football2 runAction:repeat2];

So My problem is I am using kobold2d which is using (cocos2d v1.1.0-beta2b) and when I try to play this animation it only plays through half of the frames, but then I tried this (EXACT) code in another cocos2d project which is using (cocos2d v1.0.0-rc) and it works like a charm. Is this a bug in cocos2d or am I not doing something right?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:40:54+00:00Added an answer on June 11, 2026 at 3:40 am

    I figured out how to fix my problem. Someone on the cocos2d forum suggested changing the update method in CCActionInterval.m (from this)

    -(void) update: (ccTime) t
    {
        NSArray *frames = [animation_ frames];
        NSUInteger numberOfFrames = [frames count];
        CCSpriteFrame *frameToDisplay = nil;
    
        for( NSUInteger i=nextFrame_; i < numberOfFrames; i++ ) {
            NSNumber *splitTime = [splitTimes_ objectAtIndex:i];
    
            if( [splitTime floatValue] <= t ) {
                CCAnimationFrame *frame = [frames objectAtIndex:i];
                frameToDisplay = [frame spriteFrame];
                [(CCSprite*)target_ setDisplayFrame: frameToDisplay];
    
                NSDictionary *dict = [frame userInfo];
                if( dict )
                    [[NSNotificationCenter defaultCenter] postNotificationName:CCAnimationFrameDisplayedNotification object:target_ userInfo:dict];
    
                nextFrame_ = i+1;
    
                break;
            }
        }
    }
    

    To this

    -(void) update: (ccTime) t
    {
        NSArray *frames = [animation_ frames];
        NSUInteger numberOfFrames = [frames count];
    
        NSUInteger idx = t * numberOfFrames;
    
        if( idx >= numberOfFrames )
            idx = numberOfFrames -1;
    
        CCAnimationFrame *frame = [frames objectAtIndex:idx];
        CCSpriteFrame *frameToDisplay = [frame spriteFrame];
        [(CCSprite*)target_ setDisplayFrame: frameToDisplay];
    
        NSDictionary *dict = [frame userInfo];
        if( dict )
            [[NSNotificationCenter defaultCenter] postNotificationName:CCAnimationFrameDisplayedNotification object:target_ userInfo:dict];
    }
    

    This worked for me, but I don’t know if it is the ideal fix.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

iam trying play animation with xcode,in specefic Time for example after 3 minutes play
I am trying to play a video file using JMF but it gives me
I am trying to play a song from my iPhone music library using AVPlayer.
I'm having an issue trying to load a series of sql files through our
I'm trying to get to play a simple sound file through OpenAL by referring
I am trying to play video through a webview on my Android and iPhone
I'm using JPA through the Play Framework. I'm checking to see if a User
I am trying to play a video through a link in my app. The
I'm trying to write a program that will play MP3's. This program will also
I've been trying to get started using Cocos2D-X, because I wanted to play around

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.