C++ を使用して何かをトゥイーンするためのインターフェイスを作成するにはどうすればよいですか? たとえば、次のような静的関数呼び出しを使用して、5 秒間にわたって写真をフェードインしたいと考えています。
Graphics::FadeSurface( Surface mySurface, int FrameHeight, int NumOfFrames,
int FadeDirection, double Duration )
実行する必要があるトゥイーン アクションごとにオブジェクトを作成する、ハードコードされたセットアップがあります。私は、ロジックなどを制御するために、プログラムが起動してから経過した時間を追跡する DeltaTime 変数を使用しています。私がやろうとしていることの種類を示すために、例(あまり洗練されていません)を含めました:
論理ループの例:
gameLoop( double DeltaTime ){
// ...
// logic
// ...
bool isItDone = otherClass.HaveFiveSecondsElapsed( double DeltaTime );
if( isItDone == true )
exit(1);
// ...
// logic
// ...
}
トゥイーンクラスの例:
other_Class::other_Class(){
InitialTime = 0;
InitialTime_isSet = false;
}
bool other_class::HaveFiveSecondsElapsed( double DeltaTime ){
// Setting InitialTime if it hasn't already been set
if( otherClass.InitialTime_isSet == false ){
otherClass.InitialTime = DeltaTime;
otherClass.InitialTime_isSet = true;
}
bool toReturn = false;
if( DeltaTime - InitialTime > 5 )
toReturn = true;
return toReturn;
}
どんな助けでも大歓迎です。ありがとう!