コード例 #1
0
    public override void createShape()
    {
        print("box body start");

        if (world != null)
        {
            PolygonShape shape = new PolygonShape();
            shape.SetAsBox(width / 2, height / 2);
            //    shape.SetAsBox(width / 2, height / 2, new Vector2(0, 0),  MathUtils.DegreeToRadian(rotation));//transform.rotation.eulerAngles.z));// MathUtils.RadianToDegree(48));//transform.rotation.eulerAngles.z-90));// transform.rotation.eulerAngles.z/Mathf.Deg2Rad);

            FixtureDef fd = new FixtureDef();

            fd.friction    = friction;
            fd.restitution = elasticity;

            fd.density = mass;

            fd.shape = shape;

            body.CreateFixture(fd);

            setTrasform();
            print("box def :" + fd.ToString());
            // print("mass :" + mass.ToString());
        }
    }
コード例 #2
0
ファイル: CircleBody.cs プロジェクト: quinsmpang/box2d4unity
 public override void createShape()
 {
     print("circle body start");
     if (world != null)
     {
         CircleShape shape = new CircleShape();
         shape._radius = rad;
         FixtureDef fd = new FixtureDef();
         fd.friction    = friction;
         fd.restitution = elasticity;
         fd.density     = mass;
         fd.shape       = shape;
         body.CreateFixture(fd);
         setTrasform();
         print("circle def :" + fd.ToString());
     }
 }