내 프로그램에 문제가 있습니다. 나는 화면이 화면의 다른 모든 것을 어떻게 차지하는지 이해하지 못합니다. 세부 정보, 내 코드는 다음과 같습니다 : 당신이 hitbox에서 (흰색 화면)에서 볼 수 있듯이왜 그림이 스프라이트 배치에서 다른 그림보다 먼저 나타 납니까?
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, null, null, null, null, cam.get_transformation(GestionEcran.GraphicsDevice));
//Draw the background
decor.Draw(spriteBatch, gameTime, 255);
//Draw the players
Player2.Draw(spriteBatch, gameTime);
Player1.Draw(spriteBatch, gameTime);
//Draw the foreground
decor.DrawPremierPlan(spriteBatch, gameTime, 70);
if (aPlayerisWinning== true)
{
//THIS LINE "HITBOX" IS APPEARING BEFORE PLAYERPORTRAIT!!!!!!!!!!!!!!
spriteBatch.Draw(hitBox, new Rectangle(0, 0, 500,500), new Color(255, 255, 255, 255));
spriteBatch.Draw(PlayerPortrait, new Rectangle(0,0,500,500), new Color(255, 255, 255, 255));
}
spriteBatch.End();
// USED FOR ADDITIVE BLENDING
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, null, null, null, cam.get_transformation(GestionEcran.GraphicsDevice));
{
Player1.DrawEffects(spriteBatch,gameTime);
Player2.DrawEffects(spriteBatch,gameTime);
}
spriteBatch.End();
는 PlayerPortrait 뒤에 표시해야하지만 작동하지 않습니다. 흰색 화면에는 다른 모든 도면이 표시됩니다.
의견이 있으십니까? Thx.
편집 : SpriteSortMode로 아무 것도 변경되지 않습니다. BacktoFront, FrontToBack 및 Texture가 겹쳐져 있습니다. 즉시 및 Deffered 잘 작동하지만 흰색 화면과 동일한 문제가 있습니다. 첫 번째 대답의 링크에서 deffered는 Draw와 동일한 순서로 모든 스프라이트를 하나의 배치로 그립니다. 그렇다면 마지막 전화가 걸리기 전에 왜 두 번째 전화가 먼저 나올까요?
고맙지 만 변경된 사항이 없으므로 마지막 호출에서 두 번째 호출이 마지막 호출 전에 나타납니다. – Pilispring