Skip to content

Commit 3637c36

Browse files
committed
Created the croc's mouth body and fixture
1 parent ac539a2 commit 3637c36

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

CutTheVerlet/HelloWorldLayer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
NSMutableArray *candies;
3333
b2Body* groundBody; // weak ref
3434
CCSpriteBatchNode *ropeSpriteSheet; // weak ref
35+
36+
b2Body *crocMouth_; // weak ref
37+
b2Fixture *crocMouthBottom_; // weak ref
3538
}
3639

3740
// returns a CCScene that contains the HelloWorldLayer as the only child

CutTheVerlet/HelloWorldLayer.mm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,21 @@ -(void) initPhysics
148148
// right
149149
groundBox.Set(b2Vec2(s.width/PTM_RATIO,s.height/PTM_RATIO), b2Vec2(s.width/PTM_RATIO,0));
150150
groundBody->CreateFixture(&groundBox,0);
151+
152+
// Define the croc's "mouth".
153+
b2BodyDef crocBodyDef;
154+
crocBodyDef.position.Set((s.width - croc_.textureRect.size.width)/PTM_RATIO, (croc_.position.y)/PTM_RATIO);
155+
156+
crocMouth_ = world->CreateBody(&crocBodyDef);
157+
158+
// Define the croc's box shape.
159+
b2EdgeShape crocBox;
160+
161+
// bottom
162+
crocBox.Set(b2Vec2(5.0/PTM_RATIO,15.0/PTM_RATIO), b2Vec2(45.0/PTM_RATIO,15.0/PTM_RATIO));
163+
crocMouthBottom_ = crocMouth_->CreateFixture(&crocBox,0);
164+
165+
crocMouth_->SetActive(NO);
151166
}
152167

153168
-(void) draw

0 commit comments

Comments
 (0)