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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:35:05+00:00 2026-06-14T17:35:05+00:00

I am developing a simple game app. I am required to have two screens

  • 0

I am developing a simple game app.

I am required to have two screens one on left & other on right, just like on scroll view with pagination having 2 screens to toggle between. I am detecting swipes with the help of RootViewController class and successfully swiping left and right screens.

But the problem is I have to have infinitely running rotateBy action on both screens each running this action on single sprite placed on center of screen.

I am using a main scene called SelectWorld & two are it’s sub scenes.
First screen is called factory & other is called stack.
Following is my code:

Select World Screen:

@implementation SelectWorld

+(CCScene*)scene
{
    CCScene* scene = [CCScene node];
    SelectWorld* layer = [SelectWorld node];
    [scene addChild:layer];

    return scene;
}

-(id)init
{
    if((self = [super init]))
    {
        [RootViewController singleton].swipeCallBackHandler = self;
        [[RootViewController singleton] enableSwipeDetection];

        factory = [[ColorfulFactory scene] retain];
        stack = [[CoinsStack scene] retain];

        [self addChild:factory];
        isOnFactory = YES;
    }

    return self;
}

-(void)swipedLeft
{
    if(isOnFactory)
    {
        [self removeAllChildrenWithCleanup:YES];

        isOnFactory = NO;
        CCTransitionScene* transitionalScene = [CCTransitionSlideInR transitionWithDuration:0.3 scene:stack];
        [[CCDirector sharedDirector] replaceScene:transitionalScene];
    }
}

-(void)swipedRight
{
    if(!isOnFactory)
    {
        [self removeAllChildrenWithCleanup:YES];

        isOnFactory = YES;
        CCTransitionScene* transitionalScene = [CCTransitionSlideInL transitionWithDuration:0.3 scene:factory];
        [[CCDirector sharedDirector] replaceScene:transitionalScene];
    }
}

Here’s the code for factory only, same goes for stack-

@implementation ColorfulFactory

+(CCScene*)scene
{
    CCScene* scene = [CCScene node];
    ColorfulFactory* layer = [ColorfulFactory node];
    [scene addChild:layer];

    return scene;
}

-(id)init
{
    if((self = [super init]))
    {
        CGSize size = [CCDirector sharedDirector].winSize;

        CCLabelTTF* info = [CCLabelTTF labelWithString:@"Colorful Factory" fontName:@"Helvetica" fontSize:35.0];
        info.position = ccp(size.width/2, size.height-50);
        [self addChild:info];

        CCSprite* sprite = [CCSprite spriteWithFile:@"Icon.png"];
        sprite.position = ccp(size.width/2, size.height/2);
        [self addChild:sprite];
        sprite.tag = 123;

        CCRotateBy* rotateBy = [CCRotateBy actionWithDuration:60 angle:360.0];
        CCRepeatForever* repeatForever = [CCRepeatForever actionWithAction:rotateBy];
        [sprite runAction:repeatForever];
        repeatForever.tag = 456;
    }

    return self;
}

Now the problem is, in first two swipes actions are running fine, but as soon as I try to swipe more than two or three times, actions got stopped. I haven’t written a single line to stop this in both the classes. I require it there running forever.

  • 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-14T17:35:06+00:00Added an answer on June 14, 2026 at 5:35 pm

    Your mistake is that you’re re-using the same scene object for every scene change. You can’t do that in cocos2d, you have to create a new instance of the scene object.

    You should never retain a scene object, since there ought to be only one active scene at any one time (with the exception of the duration of a scene transitioning to another scene – but that’s handled by cocos2d internally).

    For example:

    CCScene* factory = [ColorfulFactory scene];
    CCTransitionScene* transitionalScene = [CCTransitionSlideInR transitionWithDuration:0.3 scene:factory];
    [[CCDirector sharedDirector] replaceScene:transitionalScene];
    

    If you need both objects in memory, make them layers (or nodes), not scenes. Don’t use replaceScene but instead animate the layers with regular moveTo actions in and out of the screen.

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

Sidebar

Related Questions

I'm currently developing a simple 2D game for Android. I have a stationary object
I have been developing a simple game for iOS which involves dragging and using
I'd like to start developing a "simple" game with HTML5 and I'm quite confused
I'm currently developing a simple multiplayer game app for Android and I need to
i am developing simple game application just using pan gesture and cgaffinetransform rotate application
I am developing a simple game photo puzzle. I have 9 pieces of an
I'm developing simple traffic educational game like https://market.android.com/details?id=cz.allianz.krizovatky.android . When the player taps on
Long story short, I am developing a simple game, and I have a Game
I have been developing a very simple text game using Objective C and Xcode.
I am developing a multi player game app for the android. One of the

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.