-
Notifications
You must be signed in to change notification settings - Fork 12
/
demo1-1.html
executable file
·45 lines (41 loc) · 1.48 KB
/
demo1-1.html
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
<html>
<head>
<title>Demo1-1 Box2dJS</title>
</head>
<body>
<script src="js/Box2d.min.js"></script>
<script>
function init(){
var b2Vec2 = Box2D.Common.Math.b2Vec2
,b2AABB = Box2D.Collision.b2AABB
,b2BodyDef = Box2D.Dynamics.b2BodyDef
,b2Body = Box2D.Dynamics.b2Body
,b2FixtureDef = Box2D.Dynamics.b2FixtureDef
,b2Fixture = Box2D.Dynamics.b2Fixture
,b2World = Box2D.Dynamics.b2World
,b2MassData = Box2D.Collision.Shapes.b2MassData
,b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape
,b2CircleShape = Box2D.Collision.Shapes.b2CircleShape
,b2DebugDraw = Box2D.Dynamics.b2DebugDraw
,b2MouseJointDef = Box2D.Dynamics.Joints.b2MouseJointDef
;
var world;
function main(){
var gravity = new b2Vec2(0, 9.81);
var sleep = true;
world = new b2World(gravity, sleep);
setInterval(updateWorld, 1000 / 60);
}
function updateWorld() {
var timeStep = 1/30;
var velIterations = 10;
var posIterations = 10;
world.Step(timeStep,velIterations,posIterations);
world.ClearForces(); // 清除作用力
}
main();
}
init();
</script>
</body>
</html>