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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:54:47+00:00 2026-05-30T18:54:47+00:00

I have this main scene in a game and I have called the menu

  • 0

I have this main scene in a game and I have called the menu where the user can choose the parameters for the new match (number of players, level of difficulty, etc).

This menu was created on a CClayer and presented on top of the main scene using this:

CCLayer *menu = [Menu node];

id actionFadeIn = [CCFadeIn actionWithDuration:0.3];
[menu runAction:[CCSequence actions:actionFadeIn, nil]];

[self addChild:menu z:1 tag:theMenu];

This menu’s class has a basic logic there. For every parameter chosen on that menu a proper parameter is set on a singleton. Now that the user has chosen all parameters it will press the START GAME button.

When this happens, the menu has to vanish and a method called startGame has to run on the main scene, but this is my problem: How do I run the method from the menu class? I thought I could do

CCScene *currentScene = [[CCDirector sharedDirector] runningScene];
[currentScene startGame];

but I cannot do that because the current scene is not an instance itself and each of its methods can only be run from inside scene, but not from the outside.

I thought of using notifications to post an order to run the method on the class, but that sounded lame and like using a cannon to kill a fly. How the best way to do that in Cocos?

thanks.

  • 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-30T18:54:49+00:00Added an answer on May 30, 2026 at 6:54 pm

    I have a very detailed answer to your question at the following post:

    Accessing Objects in other Layers (cocos2d)

    You basically make your Scene a “semi-singleton”. Other ways are also explained in case you prefer a different approach.

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

Sidebar

Related Questions

I have this code : void Main() { System.Timers.Timer t = new System.Timers.Timer (1000);
I am newbie to Cocos2d. I have this layer that represents my main game
In the below shown html i have this main div as cxfeeditem feeditem and
I have this TreeView: Main Node Header=Main Sub Node Header=Sub1 Final Node Header=Item1 Final
I have this in my main.m: printf(make autorelease pool \n); NSAutoreleasePool * pool =
I have this declared on my main class: [[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@atlas.plist]; CCSpriteBatchNode *batchNode =
I have a GridView like this( main.xml ): <?xml version=1.0 encoding=utf-8?> <GridView xmlns:android=http://schemas.android.com/apk/res/android android:id=@+id/gridView1
On my main page I have this jquery code which does an ajax call
In the main view i have this function public function lang($file, $language){ require 'languages/'.$language.'/'.
i have this hap code of which tries to selects sub-node from the main

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.