2014-12-17 1 views
0

변수 "location"과 동일한 마우스 위치를 설정하려고 시도하지만 "암시 적으로 'void'를 'Microsoft.Xna'로 변환 할 수 없습니다. Framework.Input.MouseState "를 참조하십시오. 내가 알 수있는 한 "위치"는 무효가 아닙니다. Mouse.SetPosition() 할당 된 변수는 void로 간주됩니다.

class Player 
{ 
    private Texture2D texture; 
    private static int textureSize = 20; 
    private static int screenWidth = Game1.Instance.GraphicsDevice.Viewport.Width; 
    private static int screenHeight = Game1.Instance.GraphicsDevice.Viewport.Height; 
    private static int halfTexture = (int)(textureSize * (screenHeight/(double)textureSize))/2; 
    private Vector2 location; 
    private Rectangle destination; 
    private float speed; 
    private MouseState mouse; 

    public Player(Texture2D texture) 
    { 
     this.texture = texture; 
     this.location = new Vector2(screenWidth/2 - halfTexture, screenHeight * 3/4 - halfTexture); 
     this.destination = new Rectangle((int)location.X, (int)location.Y, textureSize, textureSize); 
     this.mouse = Mouse.SetPosition((int)location.X, (int)location.Y); // the error is here 
    } 

는 그래서 여기에 무슨 내가 그것을 어떻게 해결합니까 : 여기 인해이 작품을 만들려고 노력에 조금 어수선 코드는 무엇입니까?

+0

이 경우'location.x'와'location.y'의 값은 무엇입니까? –

+0

X는 390이어야하고 Y는 440이어야합니다. – Firearrow5235

답변

1

XNA 문서를 보지 않고 난 여전히 안전하게 Mouse.SetPosition이 -method void을 반환하고 유형 MouseState이다 this.mouse에 그것의 반환 값을 할당하려고하는 것을 말할 수있다. 과제를 삭제하면 괜찮을 것입니다.

+0

오! 알 겠어. "Mouse"클래스는 마우스의 위치를 ​​설정하는 인스턴스가 필요하지 않습니다. – Firearrow5235

관련 문제