2012-05-25 4 views
1

내가 상수 화재 동안 촬영 사이의 시간 범위를 정의하기 위해 노력하고 있지만, 다음과 같은 시도로 이상한 행동을 가지고있어 : 위의XNA, gameTime 지속적인 화재

public void Shoot(GameTime time) 
    { 
     bullets.Add(new Bullet("bullet", position, angle, content, this, bullets)); 
     shotTimer = time.TotalGameTime.Milliseconds; 
    } 
    public void ShootContinuous(GameTime time) 
    { 
     if (time.TotalGameTime.Milliseconds - shotTimer > 50) 
      this.Shoot(time); 
    } 

이 호출된다

if (newMouseState.LeftButton == ButtonState.Pressed) 
{ 
    if (oldMouseState.LeftButton == ButtonState.Released) 
    { 
     player.Shoot(time); 
     gui.ProcessClick(newMouseState); 
    } 
    else 
    player.ShootContinuous(time); 
} 

음, 동작은 다음과 같습니다. 버튼을 누르고있을 때, 버튼을 리얼리티 할 때까지 아무런 반응을하지 않고 4 ~ 10 사이의 임의의 총알 개수로 발리를 쏘습니다.

누구나 무슨 문제가 있을까요?

답변

1

코드를 올바르게 이해하면 Milliseconds이 아닌 TotalMilliseconds을 사용해야합니다.

+0

그랬습니다. 감사합니다. –