Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

TwinofSian

macrumors member
Original poster
Oct 23, 2011
53
0
I have been porting a project from cocos2d .99.4 onto the newest version of cocos2d using v 1.0.1. I copied over all the files, and changed the method names so as to update them with the new cocos2d engine.

However, I have been getting warnings regarding this:

Code:
glView = [[EAGLView alloc] initWithFrame:[window bounds]
                            pixelFormat:kEAGLColorFormatRGBA8
                            depthFormat:GL_DEPTH_COMPONENT24_OES
                           preserveBackbuffer:NO];

it said no method was listed, and it was right; I changed it to initWithView.

However, the simulator would launch, but the game would not load; the screen would not even 'flip' as it is supposed to.

The above problem drew my attention to the fact that the EAGLView instance variable in the App.h file does not appear to be defined. A jump to definition yields no results.

HOWEVER, EAGLView.h does exist, but it doesnt seem to be recognized. My own theory is that the Cocos2d template features a Platform folder with a iOS and MAC subfolder.

Before you ask, yes I selected the cocos2d iOS template, and it still saddled me with this Mac crap.
link 1
^There you can see how EAGLView has no definition

link 2
^There you can see EAGLView.h clearly exists, altho in an iOS subfolder of Platform

link 3
^Here's the current cocos2d.h file
link 4
^Here's the App.m Implementation of the EAGLView mthd. Note how EAGLView txt is colorless.

So, question in a nutshell? How do I get the EAGLView.h file to be recognized by the App.h file? Because it clearly isn't.
 
Last edited:
Have u tried importing "cocos2d.h"
It doesn't know what EAGLView is, what kind of class, because you didn't put a forward declaration or imported it.
Think that should solve this issue.

I have tried something similar in the past, but the Project's files are setup in such a way as to create a delicate loop effect wherein the iPhone Game Kit imports cocos2d and Foundation header files, while the main project imports the Game Kit, and all game files import the Game Header files. Here are some screenshots, including the result of me following your advice.

Here's the Project's header File:
Project Header File
Here's the Kit's header file:
Kit Header File

Here's the header and implementation file that is giving me all the trouble *Note, I added the suggestions: a @class declaration and an #import.*

App Header
App Implementation

Note how the console error now says that
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[EAGLView viewWithFrame: pixelFormat:depthFormat: preserveBackbuffer:sharegroup:multiSampling:numberOfSamples:]: unrecognized selector sent to instance 0x6901110'

However, when I tried

Code:
App.h

@class cocos2d;

and

Code:
App.m

#import "cocos2d.h"

The console message said:
Failed to launch simulated application: iOS Simulator failed to install the Application.

This tells me that even though I am forwarding/importing the EAGLView file, it doesn't seem to be doing the trick. The cocos2d declarations/imports seems to disrupt the loop entirely.

I feel I am close to solving this issue, any insights would be much appreciated.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.