透明な画像から不透明な画像に変換するときに、アニメーション画像に問題があります。
画像を不透明な画像から透明な画像にアニメーション化すると、正常に機能します。しかし、画像を透明な画像から不透明な画像にアニメーション化すると、機能しなくなります(それが問題です)
サンプルコード:
不透明から透明にアニメーション化:(すべてOK、機能的)
//Define variables (in construct):
float AlphaTime = 3500f; // total animate time (at milliseconds)
float AlphaTimeSubtract = 3500f; // at milliseconds
Color color = Color.White;
//Update method:
AlphaTimeSubtract -= (float)(gameTime.ElapsedGameTime.TotalMilliseconds); // abate number of elapsed time (for milliseconds)
color *= MathHelper.Clamp(AlphaTimeSubtract / AlphaTime, 0, 1);
//Draw merhod:
spriteBatch.Draw(texture, position, color);
透明から不透明にアニメーション化:(つまり、問題があり、機能しません)!!!
結果は目に見えないスプライトです!(間違っています)
正しい結果は次のようになります。スプライトを透明から不透明にアニメートします。
//Define variables (in construct):
float AlphaTime = 3500f; // total animate time (at milliseconds)
float AlphaTimeSubtract = 3500f; // at milliseconds
Color color = Color.White;
//Update method:
AlphaTimeSubtract -= (float)(gameTime.ElapsedGameTime.TotalMilliseconds); // abate number of elapsed time (for milliseconds)
color *= MathHelper.Clamp(Math.Abs(AlphaTimeSubtract - AlphaTime ) / AlphaTime , 0, 1);
//Draw merhod:
spriteBatch.Draw(texture, position, color);
Math.Abs()
:絶対値を返す
私は何が間違っているのですか?