2012-01-17 3 views
0

맞아, 내가 가지고있는 게임은 2D 자동차 경주 게임이다. 나는 게임에서 결승선 이미지를 구현했다. 그리고 별도의 스프라이트 시트로 사용했습니다. 나는 'car1blue가 finishLine1과 교차한다면, 게임을 끝내라.'와 같은 방식으로 변경하려고 시도하는 코드가있다. 그러나 나는 그걸 올바르게 이해할 수없는 것 같습니다. 다음은 변경하려는 코드입니다.XNA 4.0에서 종료 화면을 추가하는 방법은 무엇입니까?

if (IntersectPixels(destinationBlueRect, finishLine1TextureData, finishLine1Rectangle, finishLine1TextureData)) 
{ 
    blueHit = true;     
} 

어떻게 그 이후 '플레이어 1 승'과 끝 게임 (자동차 finishline1에게 교차) 약 3 초 말 최종 게임 메시지를 추가하는 나를 보여줄 수 있다면 그것은 더 나은 것입니까?

도와주세요. (저는 초보자입니다.) 고맙습니다!

답변

1

당신은 당신의 지연,이 Game State Management 시스템을 구현 할 수 있습니다 :

float delayTime = 3000;// Time to delay in milliseconds 
float delayBuffer = 0;// This will count how much time has passed 

// In your Update method 
if (blueHit) {// You should change this to whatever way you find if someone has won the game 
    if (delayBuffer < delayTime) { 
     delayBuffer += (float)gameTime.ElapsedGameTime.TotalMilliseconds; 
    } else { 
     // Show the last screen 
    } 
} 
관련 문제