I use box2dweb for my game. I placed four circles around the circle and gave the circle its initial speed. I expected the circle to bounce off the wall, but the circle would run parallel to the wall after the collision. This only happens when the circle moves slowly. The circle always stops on the wall at the end. How can I make the circle behave correctly? Below is the script.
<!DOCTYPE HTML> <html lang="ja-JP"> <head> <meta charset="UTF-8"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript" src="http://jsdo.it/Kon/box2dweb/js"></script> <script type="text/javascript"> var Ball_Speed = 2.0; var b2Vec2 = Box2D.Common.Math.b2Vec2; var b2Body = Box2D.Dynamics.b2Body; var b2World = Box2D.Dynamics.b2World; var b2CircleShape = Box2D.Collision.Shapes.b2CircleShape; var b2DebugDraw = Box2D.Dynamics.b2DebugDraw; $(function(){ "use strict"; var canvas = $("#canvas"); canvas.css("width", 500); canvas.css("height", 500); canvas.get(0).width = 500; canvas.get(0).height = 500; var world = new b2World(new b2Vec2(0, 0), true); var debugDraw = new b2DebugDraw(); debugDraw.SetSprite(canvas.get(0).getContext("2d")); debugDraw.SetDrawScale(100); debugDraw.SetFillAlpha(0.9); debugDraw.SetLineThickness(1.0); debugDraw.SetFlags(b2DebugDraw.e_shapeBit | b2DebugDraw.e_jointBit); world.SetDebugDraw(debugDraw); var fixDef = new Box2D.Dynamics.b2FixtureDef; fixDef.restitution = 1; var bodyDef = new Box2D.Dynamics.b2BodyDef; bodyDef.linearDamping = 0.2; </script> </head> <body> <canvas id="canvas"></canvas> </body> </html>
source share