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

  • Home
  • SEARCH
  • 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 295675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:28:44+00:00 2026-05-12T06:28:44+00:00

I am currently using the cocos2d Director for controlling my animation with the pause

  • 0

I am currently using the cocos2d Director for controlling my animation with the pause, resume, and stopAnimation methods. Is it also possible to use the Director to return the time that the animation has played?

I am currently using this method:

-(void)stopAnimation:(id)sender {
    //Timer initialized elsewhere: startTimer = [NSDate timeIntervalSinceReferenceDate];
    //Do other method stuff here 

    [[Director sharedDirector] stopAnimation];
    stopTimer = [NSDate timeIntervalSinceReferenceDate];
    elapsedTime = (stopTimer - startTimer);
    NSLog(@"elapsedTime = %f", elapsedTime);
}
  • 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-05-12T06:28:44+00:00Added an answer on May 12, 2026 at 6:28 am

    I looked through the Director source and didn’t see anything that would help you. I did notice that your code, as written, doesn’t take into account the time your animation was paused or when other scenes were playing.

    If that is a concern you can keep track of the elapsed time in a tick method that you schedule in your Scene or Layer.

    MyLayer.h

    @interface MyLayer : Layer {
      ccTime totalTime;
    }
    
    @property (nonatomic, assign) ccTime totalTime;
    

    MyLayer.m

    -(id)init 
    {
        if( (self = [super init]) )
        {
            [self schedule:@selector(update:)];
        }
    
        return self;
    }
    
    // deltaTime is the amount of running time that has passed
    // since the last time update was called
    // Will only be called when the director is not paused
    // and when it is part of the active scene
    -(void)update:(ccTime)deltaTime
    {
        totalTime += deltaTime;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently creating a point and click app for the iphone using cocos2d.
I am currently developing a card game for the iphone using cocos2d. I am
Currently I am using xCode 3.2.5 and I have already installed cocos2d template cocos2d
I'm currently working on a new game for iOS using Cocos2D. The game needs
I am currently making a game for the iphone using cocos2d. The game runs
Currently using cocos2d. I have a plist data name myplist.plist. Inside the plist are
I am new to Objective-C. I am currently working on a game using Cocos2D
I am creating a iphone game currently using cocos2d. The basics of the game
We have a fairly rich e-learning app, built mostly using cocos2d. Currently we are
I'm currently developing a game on iPhone using the Cocos2D API. It's going well.

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.