2013-10-27 4 views
2

방금 ​​XNA/MonoGame을 배우기 시작했고 이상한 예외가 발생했습니다.
오류는 다음과 같습니다 : The method or operation is not implemented.
거의 비슷한 코드가 작동한다는 것은 더욱 이상합니다. 유일한 차이점은 다른 코드가 XNA 및 다른 컴퓨터에서 실행되고 내 코드가 MonoGame에서 실행된다는 것입니다.MonoGame GetData 예외 구현

코드는 스프라이트 시트에서 애니메이션을 만들어야합니다. 내 클래스의 내부

, Animate :

public void set_state(string name, string state) 
    { 
     this.name = name; 
     this.state = state; 
    } 

    public void animate(int frameIndex) 
    { 
     this.frameIndex = frameIndex; 
     this.animatedTexture = Game1.contentManager.Load<Texture2D>(name + '/' + state); 

     prepare_frames(); 
     while (this.frameIndex > rectangles.Count) 
     { 
      frameIndex = frameIndex - rectangles.Count; 
     } 
     base.draw(animatedTexture, rectangles[frameIndex], origins[frameIndex]); 
    } 

    public void prepare_frames() 
    { 
     find_dots(); 
     find_rectangles(); 
     find_origins(); 
    } 

    public void find_dots() 
    { 
     cols = new Color[animatedTexture.Width]; 
     lowestRectangle = new Rectangle(0, animatedTexture.Height - 1, animatedTexture.Width, 1); 

     animatedTexture.GetData<Color>(0, lowestRectangle, cols, 0, animatedTexture.Width); 
     for (int i = 0; i < cols.Length; i++) 
     { 
      if (cols[i] == Color.Black) 
      { 
       dots.Add(new Vector2(i, animatedTexture.Height)); 
      } 
     } 
    } 

    public void find_rectangles() 
    { 
     for (int i = 0; i < dots.Count-2; i+=2) 
     { 
      rectangles.Add(new Rectangle((int)dots[i].X, 0, (int)dots[i+2].X - (int)dots[i].X, animatedTexture.Height-1)); 
     } 
    } 

    public void find_origins() 
    { 
     for (int i = 1; i < dots.Count; i++) 
     { 
      if (i%2 != 0) 
      { 
       origins.Add(dots[i]); 
      } 
     } 
    } 

뒤에 아이디어는 스프라이트 시트 아래 점의 라인은 내가 스프라이트 시트에서 프레임을 만들 수있는 그 점으로, 있다는 것입니다. , Game1 여기

#region data 

    Texture2D animatedTexture; 
    string name, state; // to determine the animated state. 

    Rectangle lowestRectangle; // is the rectangle of the dot's. 
    Color[] cols; // this array is for the colors on the dot's rectungle. 
    List<Vector2> dots = new List<Vector2>(); // this list is for the dot's coordinates on the dot's rectungle. 
    List<Rectangle> rectangles = new List<Rectangle>(); // this list is for the new rectungles, each rectungle is a diffirent frame from the sprite sheet.  
    List<Vector2> origins = new List<Vector2>(); // this list is for each origin point of the new retungles. 

    int frameIndex; 

    #endregion 

가 MonoGame의 기본 클래스에서, 상기 방법 소환 부분이다 : 여기서 클래스 Animated의 데이터이다

protected override void Draw(GameTime gameTime) 
    { 
     GraphicsDevice.Clear(Color.CornflowerBlue); 

     spriteBatch.Begin(); 

     if (Keyboard.GetState().IsKeyDown(Keys.Right)) 
     { 
      player.set_state("moshe", "run"); 
      player.animate(frameIndex); 
      frameIndex++; 
     } 
     else 
      player.draw(); 

     spriteBatch.End(); 

     base.Draw(gameTime); 
    } 

그래서 에러이 발생 라인 : 클래스 Animate의 방법 animate에서

animatedTexture.GetData<Color>(0, lowestRectangle, cols, 0, animatedTexture.Width); 

. (The method or operation is not implemented.) 오른쪽 키를 누르면. 왜 그렇게됩니까?

+0

그리고 질문은 어디에 있습니까? – pinckerman

+0

@pinckerman 죄송합니다. 왜 그런 오류가 발생하는지 묻겠습니다. 편집했습니다. 어떤 식 으로든 나는 내 대답을 얻었고, MonoGame의 버그. – Zipzap

+0

Windows 용으로 배포하지 않으면 GetData에 Monogame에 대한 알려진 문제점이 있습니다. – pinckerman

답변

1

XNA와 포트 사이에는 큰 차이가 있습니다.

NotImplementedException은 정확히 무엇을 의미합니까? 메서드 나 연산이 구현되지 않은 경우 발생합니다.

아무런 문제가 없지만 MonoGame bug tracker에보고되었으며 3.x 릴리스의 개발자에게 할당되었습니다.

그러나 SharpDX 버전을 사용하면이 오류가 존재하지 않습니다.

+0

사실이 질문은 이미 stackoverflow에 여러 번 요청되었으며, MonoGame 팀에서도 꽤 많이 논의되었습니다. 예를 들어 여기를 클릭하십시오. https://github.com/mono/MonoGame/issues/1091 – craftworkgames