My Setup
I have the following:
* Mac OS X 10.8.4
* Xcode 4.6.3
* Cocos2D-X 2.1.4 (installed as a user with ~~u)
Steps I Have Taken
- install cocos2d-x 2.1.4
<pre>
Eriador:cocos2d-x-2.1.4 wwv$ ./install~~
install-deps-linux.sh install-templates-msvc.bat install-templates-xcode.sh
Eriador:cocos2d-x-2.1.4 wwv$ ./install-templates-xcode.shuf
cocos2d-x template installer
Installing Xcode 4 cocos2d-x iOS template
—————————————————-
removing old libraries: /Users/wwv/Library/Developer/Xcode/Templates/cocos2d-x/
…creating destination directory: /Users/wwv/Library/Developer/Xcode/Templates/cocos2d-x/
…copying cocos2d files
…copying CocosDenshion files
…copying websockets files
…copying extension files
-
I add create two new files
* GameScene.h
* GameScene.m -
I run the compiler and I get an error
/Users/wwv/Projects/Game01/game04/game04/libs/cocos2dx/cocoa/CCDataVisitor.h:29:10: ‘string’ file not found
The specific line is:
#include
After reading http://stackoverflow.com/questions/7542850/compile-errors-with-include-string-in-cocoa-app, it appears I should rename the file.
- I rename GameScene.m to GameScene.mm
When I do this and recompile I get errors in both .h and .mm. Since .h is prerequisites, I am focusing on them first.
/Users/wwv/Projects/Game01/game04/game04/GameScene.h:11:24: Cannot find interface declaration for ‘CCLayer’, superclass of ‘GameScene’; did you mean ‘CALayer’?
/Users/wwv/Projects/Game01/game04/game04/GameScene.h:11:24: Attempting to use the forward class ‘CALayer’ as superclass of ‘GameScene’
Clue?
The only possible thing I have noticed is that while I can see cocos2d projects when I create a new project, I do not see any cocos2d templates when I create new files. I do not know if this is important or not, though.
Files
//
// GameScene.h
// game02
//
// Created by Ward W. Vuillemot on 2013/07/02.
//
//
#import
#import "cocos2d.h"
@interface GameScene : CCLayer
{
}
+(id) scene;
@end
//
// GameScene.m
// game02
//
// Created by Ward W. Vuillemot on 2013/07/02.
//
//
#import "GameScene.h"
@implementation GameScene
+(id) scene
{
cocos2d::CCScene *scene = [cocos2d::CCScene node];
CCLayer* layer = [GameScene node];
[scene addChild:layer];
return scene;
}
-(id) scene
{
if((self = [super init]))
{
CCLOG(@"%@ : %@", NSStringFromSelector(_cmd), self);
}
return self;
}
-(void) dealloc
{
CCLOG(@"%@ : %@", NSStringFromSelector(_cmd), self);
// always call [super dealloc]
[super dealloc];
}
@end