iOS Box2d Create Shape Error

Wellington2k

macrumors regular
Original poster
Jun 4, 2011
131
0
Hello.

Once again I am having trouble with physics.

I have this code:
Code:
bound->CreateShape(bounddef);
It gives me the error:
No member named 'CreateShape' in 'b2body'
Here is my entire code for making a floor object:
Code:
-(void)makebound {
    b2PolygonShape bounddef;
    b2FixtureDef boundfix;
    b2BodyDef boundbodydef;
    b2Body* bound;
    b2Vec2 verticies [4];
    b2Vec2(verticies [0]).Set(0 / ratio, 0 / ratio);
    b2Vec2(verticies [1]).Set(550 / ratio, 0 / ratio);
    b2Vec2(verticies [2]).Set(550 / ratio, 10 / ratio);
    b2Vec2(verticies [3]).Set(0 / ratio, 10 / ratio);
    bounddef.Set(verticies, 6);
    boundfix.shape=&bounddef;
    boundfix.density = 0.0;
    boundfix.friction=0.5;
    boundfix.restitution = 0.3;
    bound->CreateFixture(&boundfix);
    boundbodydef.position.Set(0 / ratio, 390 / ratio);
    bound = World->CreateBody(&boundbodydef);
    bound->CreateShape(bounddef);
    
}
What's wrong?
 

chown33

Moderator
Staff member
Aug 9, 2009
8,552
4,611
inter-prandial
You have this type declaration:
Code:
b2Body* bound
Ask yourself: Does the b2Body class have a CreateShape method?

I assume you can look this up in the reference doc.

If your answer is "Yes", then point to it in the reference doc. That is, post the URL of the ref doc, showing the existence of that method.


Also, this code:
Code:
    bound->CreateFixture(&boundfix);
may be calling CreateFixture on an uninitialized pointer.
 

Wellington2k

macrumors regular
Original poster
Jun 4, 2011
131
0
I get you.

Well I'm having an issue with b2World.cpp and b2BlockAllocator.cpp.

When ever I run my app I get this:
Warning: the current language does not match this frame.
Current language: auto; currently c++
 
Last edited:

Wellington2k

macrumors regular
Original poster
Jun 4, 2011
131
0
I found the problem is not with this error, it's with this code:
Code:
-(void)createagain {
    b2BodyDef groundBodyDef;
    groundBodyDef.position.Set(0, 0);
    b2PolygonShape groundBox;
    b2Vec2 verticies [4];
    (verticies [0]).Set(0, 0);
    (verticies [1]).Set(550 / ratio, 0);
    (verticies [2]).Set(550 / ratio, 10 / ratio);
    (verticies [3]).Set(0, 10 / ratio);
    int32 vcount = 4;
    groundBox.Set(verticies, vcount);
    b2Body* groundBody = World->CreateBody(&groundBodyDef);
    groundBody->CreateFixture(&groundBox, 0);
}
What's wrong with this code?
 

chown33

Moderator
Staff member
Aug 9, 2009
8,552
4,611
inter-prandial
What is the error message?

Or are you saying the code compiles but doesn't run? In that case, post the crash log or other debugging information.

Posting uncommented code with nothing but a "What's wrong?" isn't a useful description.

You should describe what you expected to happen, and then describe what actually happened. "I expected it to compile. It didn't, producing the following error message: Actual error message goes here". That's an example of a description.
 

Wellington2k

macrumors regular
Original poster
Jun 4, 2011
131
0
Found out the problem was that is needed to be in the viewdidload function.

Stay tuned!

I might need some more help!