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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:40:42+00:00 2026-05-26T23:40:42+00:00

I am trying to attach my CCScene class to my EAGLView. So my EAGLView

  • 0

I am trying to attach my CCScene class to my EAGLView. So my EAGLView is an IBOutlet in Class 1. I connected it and settered and gettered it. Then in my ViewDidLoad in my Class 1 I do:

[[CCDirector sharedDirector] setOpenGLView:self.eaglView];
[[CCDirector sharedDirector] runWithScene:[CCSceneClass node]];

The problem is it is not calling the class that I show below in my CCScene class (I tested with NSLogs). Anyway lets say my CCScene class is named CCSceneClass, how would I properly connect it from my ViewDidLoad from Class1 (My UIViewController) so that this method in my CCScene class gets called?

Also this is some code that I do in this method if this matters at all:

-(id)initWithEaglView:(EAGLView*)view {
NSLog(@"initWithEAGLView");
        //Attach CCDirector to EAGLView
        director = [CCDirector sharedDirector];
        [director setOpenGLView:view];
        //Make CCLayer and CCScene
        CCScene *scene = [CCScene node];
        CCLayer *layer = [CCLayer node];
        [scene addChild:layer];
        [director runWithScene:scene];
        [director setDisplayFPS:NO];
}

Thanks!

My Issue:

1. What is the point of these 2 lines (btw the first line came up with a warning saying that, that method was not found:

[director setDirectorType:kCCDirectorTypeDisplayLink];
[director setAnimationInterval:1.0/60];

I already have a game loop in my CCLayer class so does that mean I can just get rid of these lines?

That is the only question I have left!

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-26T23:40:43+00:00Added an answer on May 26, 2026 at 11:40 pm

    You can not “connect” a CCScene class with the OpenGL view, and there’s no need to really.

    After you’ve set the eaglView you would proceed as normal to run your scene with CCDirector:

    [[CCDirector sharedDirector] setOpenGLView:self.eaglView];
    ...
    [[CCDirector sharedDirector] runWithScene:[CCSceneClass node]];
    

    If you need access to the eaglView inside your scene class, you get this via CCDirector:

    EAGLView* view = [CCDirector sharedDirector].openglView;
    

    UPDATE:

    Full code to initialize Cocos2D view in a UIKit app:

    CCDirector* director = [CCDirector sharedDirector];
    [director setDirectorType:kCCDirectorTypeDisplayLink];
    [director setAnimationInterval:1.0/60];
    [director setOpenGLView:(EAGLView*)subview];
    [director runWithScene:[HelloWorldLayer scene]];
    

    There’s a chapter in my Learn Cocos2D book explaining integration of Cocos2D in a UIKit app (and vice versa) in more detail. You can also download the book’s source code (2nd edition) from that page and look at the Chapter 15 example project “ViewBasedAppWithCocos2D”.

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

Sidebar

Related Questions

I'm trying to attach a click function that adds a CSS class to all
I have a user class, where I am trying to attach a profile created
I am trying to attach 'click' events to all elements of a particular class.
I'm trying to attach a PDF attachment to an email being sent with System.Net.Mail.
I'm trying to attach an external mdf file to my SQLEXPRESS instance from within
I'm trying to attach an entity in LINQ to SQL but it throws the
I'm trying to attach my database on a server that is running SQL2005 and
I'm trying to attach < Previous and Next > links to a jQueryUI datepicker
I am trying to attach a function-object to be called on destruction of a
I'm having trouble trying to attach a custom tracking participant in workflow foundation 4.0.

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.