Skip to content

Paused CCNode subclass callbacks still called when update method is not implemented #889

Open
@tomfielder

Description

@tomfielder

I can't see this as defined behaviour in the docs, so I'm assuming it's a bug. When pausing a subclass of CCNode, any scheduled callbacks are not paused unless you have an update method defined. After looking at CCScheduler, I'm guessing it's caused by or related to the fact that it won't schedule anything unless it has the update/fixedUpdate method implemented. I'm using XCode 5.1.1, OS X 10.9.4, and the latest 3.1.1 version of Cocos2D.

To replicate, if you add this sprite to your scene and [bomb collect] it, it should still explode (until you implement the update method).

@interface BombSprite : CCSprite
- (void)collect;
@end

@implementation BombSprite
- (void)collect
{
    // Explode after 5 seconds.
    [self scheduleOnce:@selector(explode) delay:5.0f];

    // Pausing has no effect.
    self.paused = true;
}

- (void)explode
{
    NSLog(@"Boom");
}
@end

The bomb will always explode. After adding an update method, it pauses as expected.

- (void)fixedUpdate:(CCTime)delta
{
    // Empty method will cause the pause to work.
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions