Jan 05
Problems with Obj-C
xn--vcsx75gvhj1xc.com/* Game */
#import
@class GameView, GameController;
enum { STATE_TITLE, STATE_PLAYING, STATE_GAME_OVER }
@interface Game : NSObject //parse error befor 'interface'
{
IBOutlet GameController *gameController;
IBOutlet GameView *gameView;
int state;
} //parse error before token '{'
- (void)setState: (int)newState; //fatal error metod definition not in class context (sorry, needed the space so that it wasn't a frown here on the forums)
- (int)state;
@end
Thanks and which one?
[Session started at 2005-04-29 07:30:38 -0400.]
ZeroLink: unknown symbol '_glClearColor'
Executable â œFlipSquareâ has exited due to signal 6 (SIGABRT).
And the code:
#import "GameView.h"
#import "Game.h"
#import "GameView.h"
@implementation GameView
- (id)initWithFrame: (NSRect)frameRect
{
if ((self = [super initWithFrame:frameRect]) != nil) {
// Add initialization code here
}
return self;
}
- (void)drawRect: (NSRect)rect
{
}
switch([game state])
{
case STATE_TITLE:
[self displayTitle:rect];
break;
case STATE_PLAYING:
[self displayPlaying:rect];
break;
case STATE_GAME_OVER:
[self displayGameOver:rect];
break;
glFinish();
[[self openGLContext] flushBuffer];
- (void)displayTitle: (NSRect)rect { }
- (void)displayPlaying: (NSRect)rect {
glClearColor(0,0,1.0f,0);
glClear(GL_COLOR_BUFFER_BIT);
}
- (void)displayGameOver: (NSRect)rect { }
}
@end
2) the second error is symptomatic of the first.
enum { STATE_TITLE, STATE_PLAYING, STATE_GAME_OVER }; // At the end
/* Game */
#import
@class GameView, GameController;
enum; { STATE_TITLE, STATE_PLAYING, STATE_GAME_OVER }
@interface Game : NSObject
{
IBOutlet GameController *gameController;
IBOutlet GameView *gameView;
int state;
}
- (void)setState: (int)newState; //parse error before semi-colon
- (int)state;
@end
#import "GameView.h"
#import "Game.h"
#import "GameView.h"
#import
@implementation GameView
- (id)initWithFrame: (NSRect)frameRect
{
if ((self = [super initWithFrame:frameRect]) != nil)
{
// Add initialization code here
}
return self;
}
- (void)drawRect: (NSRect)rect
{
switch([game state])
{
case STATE_TITLE:
[self displayTitle:rect];
break;
case STATE_PLAYING:
[self displayPlaying:rect];
break;
case STATE_GAME_OVER:
[self displayGameOver:rect];
break;
}
glFinish();
[[self openGLContext] flushBuffer];
}
- (void)displayTitle: (NSRect)rect
{
}
- (void)displayPlaying: (NSRect)rect
{
glClearColor(0,0,1.0f,0);
glClear(GL_COLOR_BUFFER_BIT);
}
- (void)displayGameOver: (NSRect)rect
{
}
@end
#If you have any other info about this subject , Please add it free.# |