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 5989803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:09:13+00:00 2026-05-22T23:09:13+00:00

I want to schedule a @selector(count) interval: 1.0f to count the time left. here

  • 0

I want to schedule a @selector(count) interval: 1.0f to count the time left.
here is my code: (In GameManager.m file)

-(void) count {
duration++;
[[[GameScene sharedScene] gadgetLayer] updateTimerLabel];
if (timeLimit - duration <= 5 && ticking == NO) {
    ticking = YES;
    [self schedule:@selector(untick) interval:5];
    [[SimpleAudioEngine sharedEngine] playEffect:@"tick.caf"];
}
if (duration >= timeLimit) {
    [self lose];
}
}

gadgetLayer is where i put timerLayer and scoreLayer stuff.
the the count is not scheduled in GameManager.m, instead, i put it in my GameScene.m file:

-(void) onEnter {
[[GameManager sharedManager] schedule:@selector(count) interval:1.0];
[super onEnter
}


- (void)onExit {
[[GameManager sharedManager] unschedule:@selector(count)];
[super onExit];
}

But the timerLabel won’t change. The count method is in GameManager.m file, does it have to be inside GameScene.m file? Anything wrong with it?

+(GameManager*) sharedManager {
if (instanceOfGameManager == nil) {
    return [[GameManager alloc] init];
}
else return instanceOfGameManager;
}


-(id) init {
if ((self = [super init])) {
    instanceOfGameManager = self;

    [self scheduleUpdate];
}
return self;
}`


-(void) update: (ccTime) delta {
    int a = 2;

}

`

i set a breakpoint in ‘int a = 2’ line, but can not be reached.
[GameManager sharedManager] is called in appDidFinishLaunching method, so it won’t be alloc’ed and init’ed again i guess.

  • 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-22T23:09:13+00:00Added an answer on May 22, 2026 at 11:09 pm

    Actually I don’t know why, but it work:

    -(void) onEnter {
        GameManager *sharedManager = [GameManager sharedManager];
        [[CCScheduler sharedScheduler] scheduleSelector:@selector(count)
                                              forTarget:sharedManager
                                               interval:1.0
                                                 paused:NO];
    
    //    [self schedule:@selector(tick:) interval:0.5];
    }
    

    Answering next question:

    Unscheduling using sharedScheduler works perfect. Your problem is that you don’t receive touch events because you’ve forgot [super onEnter] (and by the way super onExit) in HelloWorld.m and super onEnter is the place where CCLayer makes self registration with touchDispatcher. If you will add this everything will work.

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

Sidebar

Related Questions

I want to schedule the email with asp.net and C# code. what is basic
I want to plan a schedule maintenance down time on one of my production
I want to schedule my jasper report so that at a particular time, it
I want to schedule push notification after some time or say after 2 days
I want to schedule events to happen for my users. Is there an efficient
I am running a SVN server on my Windows Server and want to schedule
I want a way to be able to schedule callbacks, I want to be
I want to write a windows service which the user can schedule. i.e, the
I want to run a sql query on a specific schedule (weekly) and need
I want to schedule job that would run immediately once the server is up,

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.