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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:03:14+00:00 2026-05-31T19:03:14+00:00

So I’m trying to implement the alterTime method from the EaseActionsTest example from the

  • 0

So I’m trying to implement the alterTime method from the EaseActionsTest example from the Cocos2D example into my game.

I’m trying to implement this idea into my game to create a freeze-time type of powerup for my game. I’ve set up a separate HUDLayer with a CCMenu to change the CCSpeed of the asteroids to 0 to stop moving. I’ve set up a CCLog to make sure my freezeTime method was being called, which it does, but the CCSpeeds of the asteroids remain unaffected. Here is my code for more clarity.

HUDLayer.h

#import "ActionLayer.h"

@interface HUDLayer : CCLayer {
    GameObject *asteroid;
}

-(void)freezeTime:(ccTime)dt;

HUDLayer.mm

-(void)freezeTime:(ccTime)dt
{
    id action = [asteroid getActionByTag:kTagAsteroidAction];
    [action setSpeed:0.0f];
    CCLOG(@"Freeze!");
}

-(void)createPowerUpButtons
{
    CGSize winSize = [CCDirector sharedDirector].winSize;
    CCSprite *freeze = [CCSprite spriteWithSpriteFrameName:@"powerup.png"];
    CCMenuItem *freezeButton = [CCMenuItemImage itemFromNormalSprite:freeze selectedSprite:nil target:self selector:@selector(freezeTime)];

    CCMenu *powerUpMenu = [CCMenu menuWithItems:freezeButton, nil];
    powerUpMenu.position = ccp(winSize.width * 0.5, winSize.height * 0.1);
    [self addChild:powerUpMenu];
}

-(id)init
{
    if( (self = [super init]) )
    {
        [self createPowerUpButtons];
    }
    return self;
}

ActionLayer.h

#import "HUDLayer.h"
#import "GameObject.h"

enum Actions
{
    kTagAsteroidAction = 1
};
@interface ActionLayer : CCLayer
{
    GameObject *asteroid;
}

ActionLayer.mm

-(void)updateAsteroids:(ccTime)dt
{
    // ---------------------------------------------
    //  Code to set random sizes and speeds for the asteroids from the array...
    // ---------------------------------------------

        // Move it offscreen to the left, and when it's done, call removeNode
        id action = [CCSequence actions:
                     [CCMoveBy actionWithDuration:randDuration position:ccp(-winSize.width - asteroid.contentSize.width, 0)],
                     [CCCallFuncN actionWithTarget:self selector:@selector(invisNode:)], nil];
        [action setTag:kTagAsteroidAction];

        [asteroid runAction:[CCSpeed actionWithAction:action speed:1.0f]];

        [self schedule:@selector(freezeTime:) interval:1.0f];
    }
}

-(void)update:(ccTime)dt
{
    [self updateAsteroids:dt];
}

I tried to get as close to as the EaseActionsTest example as I could, but I keep getting this error on startup:

'+[NSInvocation invocationWithMethodSignature:]: method signature argument cannot be nil'

I think it’s because of the -(void)freezeTime:(ccTime)dt, because prior to this, I was originally trying with just -(void)freezeTime; I would receive the CCLog I set in the freezeTime method seeing that it was being called, but the asteroids’ speeds were not affected.

Also, I tried:

-(void)freezeTime
{
    id action = [asteroid getActionByTag:kTagAsteroidAction];
    [action setSpeed:0.1f];
    CCLOG(@"Freeze!");
}

-(id)init
{
    if( (self = [super init]) )
    {
        [self freezeTime];
    }
    return self;
}

I just noticed that the speeds are NOT affected here either.

Any ideas on what I can do to make this work? Any helpful ideas are always appreciated!

  • 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-31T19:03:15+00:00Added an answer on May 31, 2026 at 7:03 pm

    Hmm… I think theres a bug on when you are deciding to run the action on your asteroids. Actions are supposed to work over time, and you normally run the action one time, and wait for it to finish. I see you are adding actions to the asteroids EVERY FRAME, which could be the problem. I would change the name of the function as well as how many times its called.

    -(void)createAsteroidMovement: (GameObject*) asteroid
    {
        // ---------------------------------------------
        //  Code to set random sizes and speeds for the asteroids from the array...
        // ---------------------------------------------
    
            // Move it offscreen to the left, and when it's done, call removeNode
            id action = [CCSequence actions:
                         [CCMoveBy actionWithDuration:randDuration position:ccp(-winSize.width - asteroid.contentSize.width, 0)],
                     [CCCallFuncN actionWithTarget:self selector:@selector(invisNode:)], nil];
            [action setTag:kTagAsteroidAction];
    
            [asteroid runAction:[CCSpeed actionWithAction:action speed:1.0f]];
    
            [self schedule:@selector(freezeTime:) interval:1.0f];
        }
    }
    
    -(void)update:(ccTime)dt
    {
         if (!_createdAsteroidMovement)
         {
             [self createAsteroidMovement: asteroid];
             _createdAsteroidMovement = true;
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to create an if statement in PHP that prevents a single post

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.