2014-03-02 2 views
0

행맨 (hangman) 게임을위한 키보드 디스플레이 용 Sprite 객체의로드 및 처리를 구현하기 위해 for 루프를 사용합니다. 루프가 네 번째 반복을 완료하고 충돌합니다. 그것은 나를주는 오류는 말한다 :안드로이드의 배열에 여러 텍스처로드 Andengine

Texture must not exceed the bounds of the atlas 

이 실제로 모든 이미지는 64 × 64이고지도 책과 같은 선언으로 작동합니다 : 나는지도 책의 배열 및 배열을 사용하고

this.mAtlas[i] = new BitmapTextureAtlas(this.getTextureManager(),256, 256,TextureOptions.BILINEAR); 

이미지를로드 할 텍스쳐와 나는 아틀라스를로드합니다. 그런 다음 스프라이트를 구현하는 사용자 정의 클래스에 텍스처를 전달합니다. 마지막으로로드 된 스프라이트를 장면에 첨부합니다.

for(int i = 0; i < 28; i++) 
{ 
    String name = Integer.toString(i); 
    name+= ".png"; 
    this.mAtlas[i] = new BitmapTextureAtlas(this.getTextureManager(),256, 256,TextureOptions.BILINEAR); 
    this.mTexture[i] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mAtlas[i], this, name, (i*64) + 5,0); 
    this.mAtlas[i].load(); 
    if(i % 13 == 0) 
    {    
     yPos -= 64; 
    } 
    if(i < 26) 
    { 
     letterPass = alphabet.substring(i); 
    } 
    else if(i == 26) 
    { 
     letterPass = "BackSpace"; 
    } 
    else if(i == 27) 
    { 
     letterPass = "return"; 
    } 
    letters[i] = new Letter((i * 64)+ 5.0f, yPos, this.mTexture[i].getHeight(), this.mTexture[i].getHeight(), this.mTexture[i], this.mEngine.getVertexBufferObjectManager()); 
    letters[i].setLetter(letterPass); 
    mScene.attachChild(letters[i]);  
} 

충돌이 발생하는 라인은 다음과 같습니다 :

this.mTexture[i] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mAtlas[i], this, name, (i*64) + 5,0); 

나는 그것이 충돌 왜 알아낼 수 없습니다 내가 어떤 도움

답변

1
에게 감사하겠습니다 여기에 루프에 대한 전체 코드는

텍스처 아트라스는 256x256 픽셀 큽니다. 스프라이트는 64x64 픽셀이며 각각의 아틀라스를 만듭니다 ... 즉, 많은 공간을 낭비하고 있음을 의미합니다. 그리고 심지어는이 라인에 있기 때문에 작동하지 않습니다 당신은 위치 [i * 64 + 5, 0]에서 아틀라스에 텍스처를 배치 할

this.mTexture[i] = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mAtlas[i], this, name, (i*64) + 5,0); 

. 4 번째 텍스처에서 실패 할 것입니다. 3 * 64 + 5 +64 = 261, 범위를 벗어났습니다.