コード例 #1
0
    //public cpBodyType BodyType { get { return mRigidbody2D.bodyType; } set { mBodyType = value; mRigidbody2D.SetBodyType(mBodyType); } }

    //public float Mass { get { return mRigidbody2D.GetMass(); } set { mMass = value; mRigidbody2D.SetMass(mMass); } }
    public void Init()
    {
        mRigidbody2D = new cpBody(mMass, mMonent);
        mRigidbody2D.SetBodyType(mBodyType);
        mRigidbody2D.SetPositionUpdateFunc(UpdatePosition);//Set Update Poition callback

        cpVect pos = new cpVect(this.transform.position.x * XSpaceManager.PixelsPerUnit, this.transform.position.y * XSpaceManager.PixelsPerUnit);

        mRigidbody2D.SetPosition(pos);
        mRigidbody2D.SetAngle(cp.cpfradian(this.transform.eulerAngles.z));
        // mRigidbody2D.SetTransform(pos, cp.cpfradian(this.transform.eulerAngles.z)); //设置这个不对,position不更新

        //X.Tools.LogUtils.Debug(X.Tools.LogTag.Test, this.gameObject.name + ":" + mRigidbody2D.GetPosition().ToString());
        //this.transform.SetPositionAndRotation(Vector3.zero, Quaternion.Euler(0, 0, 0));
        //X.Tools.LogUtils.Debug(string.Format("rotation:{0}, eulerAngles:{1}, {2} ,{3}", this.transform.rotation, this.transform.eulerAngles, this.transform.localRotation, this.transform.localEulerAngles));
    }