-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathB2Components.cpp
More file actions
50 lines (39 loc) · 799 Bytes
/
B2Components.cpp
File metadata and controls
50 lines (39 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "B2Component.h"
B2Component::B2Component()
{
this->world = world;
}
B2Component::B2Component(b2BodyDef bodyDefine)
{
this->world = world;
DefineBody(bodyDefine);
}
B2Component::B2Component(b2BodyDef bodyDefine, b2FixtureDef fixtureDefine)
{
this->world = world;
DefineBody(bodyDefine);
SetFixture(fixtureDefine);
}
B2Component::~B2Component()
{
if (body != nullptr)
world->DestroyBody(body);
body = nullptr;
}
b2Body* B2Component::DefineBody(b2BodyDef bodyDefine)
{
body = world->CreateBody(&bodyDefine);
return body;
}
b2Fixture* B2Component::SetFixture(b2FixtureDef fixtureDefine)
{
return body->CreateFixture(&fixtureDefine);
}
void B2Component::SetWorld(b2World* world)
{
B2Component::world = world;
}
void B2Component::Update()
{
}
b2World* B2Component::world;