简体   繁体   中英

How to use MonoGame's Curve class

I am developing a game using the MonoGame Library and I want to use the Curve class for the jump force, but I can't seem to figure out how to use it. I've looked at the docs and also on github .

The CurveKeyCollection in the Curve class is private and the constructor doesn't accept any arguments, so how do you actually add/remove/edit the keys?

Use the instance property Keys to access the CurveKeyCollection .

// Position on the curve.
float position;

//Value of the control point.
float value;

//Tangent approaching point from the previous point on the curve.
float tangentIn;

//Tangent leaving point toward next point on the curve.
float tangentOut;

// CurveContinuity enum:
// CurveContinuity.Smooth
// CurveContinuity.Step

Curve curve = new();
curve.Keys.Add(new CurveKey(position, value, tangentIn, tangentOut, CurveContinuity.Smooth));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM