2011-03-20 2 views
0

스프라이트가 괜찮게 회전 할 수 있지만 비트 맵이 많이 아래로 이동하고 어떤 각도로 보았을 때 이미지의 일부를 잘랐습니다. 회전 된 비트 맵을 전환하는 중입니다. 예를 들어 공격 할 때처럼 4 개의 공격 이미지를 전환합니다. 이미지의 마지막 프레임에서 스프라이트 검은 밖으로 나오고 앞으로 향하게되고 스프라이트의 중심점은 그가 공격하지 않을 때 최초의 첫 번째 프레임과 동일하지 않습니다. 비트 맵의 ​​중심에서 여전히 회전해야하고 영웅이 어디에 있든 문제가되지 않기 때문에이 점이 중요하지 않다는 인상하에 있습니다. 또는 번역 포인트 등을 재설정해야합니까? 그러나 내가 틀렸다면 나를 바로 잡으십시오. 여기에 내가 사용하고있는 코드가있다. 제발 조언. 안드로이드의 회전 도움말

 public void draw(Canvas canvas, int pointerX, int pointerY) { 
     // setBitmap(MainGamePanel.testIcon); 
     if (setRotation) { 
      canvas.save(); 
      m.reset(); 
      // get rotation for ninja based off of joystick 
      m.setTranslate(spriteWidth/2, spriteHeight/2); 
      m.postRotate((float) GameControls.getRotation(), spriteWidth/2, 
        spriteHeight/2); 
      // rotate ninja 
      flipedSprite = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), 
        bitmap.getHeight(), m, true); 
      // set new bitmap to rotated ninja 
      setBitmap(flipedSprite); 
      setRotation = false; 
      canvas.restore(); 
     }

// create the destination rectangle for the ninjas animation pointerX // and pointerY are from the joystick moving the ninja around destRect = new Rect(pointerX, pointerY, pointerX + spriteWidth, pointerY + spriteHeight); canvas.drawBitmap(bitmap, getSourceRect(), destRect, null); }

답변

0

회전 할 공간을 늘리기 위해 원본 이미지를 조금 더 크게하여 고정 시켰습니다. 최선의 해결책은 아니지만 나를 위해 일합니다.