Box2D Forums

It is currently Thu May 23, 2013 2:53 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Mar 13, 2012 3:57 pm 
Offline

Joined: Fri Mar 09, 2012 1:43 pm
Posts: 69
Hi,

Ive been working with 2 projects since Xcode 3.2, using cocos2d 0.9. I ran through the complete RW SpaceViking Tutorial from Ray Wenderlich's new book and i made it through 3 scenes with box2d and debug draw. Then (in Xcode 4.0) i created my own game called PlanetHopper and successfully created a chipmunk and 2 box2d scenes again.

I started working on a new project, MZ, without box2d and then upgraded to Xcode 4.2 and upgraded to cocos2d 1.0. Now I finally upgraded to Xcode 4.3 last month and I added Box2d to my existing project, MZ, and i can run the scene just fine with the box2D import and .mm termination. It even runs fine with some basic box2d code such as:

- (void)setupWorld {
b2Vec2 gravity = b2Vec2(0.0f, -10.0f);
bool doSleep = true;
world = new b2World(gravity, doSleep);
}

- (void)setupDebugDraw {
debugDraw = new GLESDebugDraw(PTM_RATIO *[[CCDirector sharedDirector]
contentScaleFactor]);
world->SetDebugDraw(debugDraw);
debugDraw->SetFlags(b2DebugDraw::e_shapeBit);
}

- (void)createBoxAtLocation:(CGPoint)location withSize:(CGSize)size {
b2BodyDef bodyDef;
bodyDef.type = b2_dynamicBody;
bodyDef.position =
b2Vec2(location.x/PTM_RATIO, location.y/PTM_RATIO);
b2Body *body = world->CreateBody(&bodyDef);

b2PolygonShape shape;
shape.SetAsBox(size.width/2/PTM_RATIO, size.height/2/PTM_RATIO);
b2FixtureDef fixtureDef;
fixtureDef.shape = &shape;
fixtureDef.density = 1.0;
body->CreateFixture(&fixtureDef);


}

-(id)init{
if ((self = [super init])) {
CGSize winSize = [CCDirector sharedDirector].winSize;
CCLabelTTF *label = [CCLabelTTF
labelWithString:@"Hello, Mad Dreams of the Dead!"
fontName:@"Helvetica" fontSize:24.0];
label.position = ccp(winSize.width/2, winSize.height/2);
[self addChild:label];
/*
[self setupWorld];
[self setupDebugDraw];
[self scheduleUpdate];
self.isTouchEnabled = YES;
*/
}
return self;
}

-(void)update:(ccTime)dt {
int32 velocityIterations = 3;
int32 positionIterations = 2;
world->Step(dt, velocityIterations, positionIterations);
}

-(BOOL) ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event {
CGPoint touchLocation = [touch locationInView:[touch view]];
touchLocation = [[CCDirector sharedDirector]
convertToGL:touchLocation];
touchLocation = [self convertToNodeSpace:touchLocation];
b2Vec2 locationWorld =
b2Vec2(touchLocation.x/PTM_RATIO, touchLocation.y/PTM_RATIO);
[self createBoxAtLocation:touchLocation
withSize:CGSizeMake(50, 50)];
return TRUE;
}

-(void) draw {
glDisable(GL_TEXTURE_2D);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
world->DrawDebugData();
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_COLOR_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
}

- (void)dealloc {
if (world) {
delete world;
world = NULL;
}
if (debugDraw) {
delete debugDraw;
debugDraw = nil;
}
[super dealloc];
}

The only problem being the setupDebugDraw method above. With it I get 2 GLESDebugDraw::GLESDebugDraw(float) error...

If I remove the setupDebugDraw method it works fine.

I have checked them (.h & .m) vs the originals from SpaceViking & PlanetHopper & MZ and they are identical (using FileMerge). Im not sure what could be wrong with my GLES-Render files, or where the problem may lie. Could you help me out?


Attachments:
Screen Shot 2012-03-13 at 4.45.15 PM.png
Screen Shot 2012-03-13 at 4.45.15 PM.png [ 247.39 KiB | Viewed 1194 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group