AndEngine input error: Delivered pTextureAtlasSource must not exceed texture borders

im new for games in android and it starts and starts and encounters a problem when using createTiledFromAsset the code in which the im problem occurs is

@Override public void onLoadResources() { mBitmapTextureAtlas = new BitmapTextureAtlas(128, 128, TextureOptions.BILINEAR); BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); mPlayerTextureRegion = BitmapTextureAtlasTextureRegionFactory .createTiledFromAsset(this.mBitmapTextureAtlas, this, "move.png", 0, 0, 10, 1); mEngine.getTextureManager().loadTexture(mBitmapTextureAtlas); } @Override public Scene onLoadScene() { mEngine.registerUpdateHandler(new FPSLogger()); mMainScene = new Scene(); mMainScene .setBackground(new ColorBackground(0.09804f, 0.6274f, 0.8784f)); player = new AnimatedSprite(0, 0, mPlayerTextureRegion); mMainScene.attachChild(player); return mMainScene; } 

im does not get an error, since my BitmapTextureAtlas has a value of 128 * 128, and each tile part coming from createTiledFromAsset should have a value of 78 * 85, since the arguments passed to it are 1 row and 10 columns, and the original image is 779 * 85 this means that when the width is tiled up to 10 parts, then 779/10 = 78, the width of which will be equal to the width of each tile part, and since the line is 1, therefore 85/1 = 85, therefore, the width * of the height of each tile the details that should be placed on the BitmapTextureAtlas is 78 * 85, and the BitmapTextureAtlas itself has p zmer 128 * 128, why an error saying Supplied pTextureAtlasSource must not exceed bounds of Texture happening here ...? or they donโ€™t understand the actual functions ...? if im wrong, then how does the createTiledFromAsset ........ process work?

+4
source share
2 answers

If I understood BitmapTextureAtlas correctly, you are trying to put a 779 * 85 image in a small 128 * 128 space. TextureAtlas is a large canvas on which you have to place a lot of images. These images are later available using the TextureRegion object, which basically determines the size and coordinates of the smaller image on the canvas. The createTiledFromAsset method probably copies the original 1: 1 image into TextureAtlas and saves the coordinates of the tiles.

Please note that TextureRegion has nothing to do with the image itself, it is just a โ€œpointerโ€ to the place in TextureAtlas where the image is stored.

To understand what TextureAtlas is, look at the amazing photos at the bottom of this page: http://www.blackpawn.com/texts/lightmaps/default.html

+2
source

I also found the same problem. I use a large sheet of sprites and try to use it. after searching, I found some tips in this tutorial: getting-started-working-with-images , and I understand that the width and height value is used in:

BitmapTextureAtlas(WIDTH, HEIGHT ,TextureOptions.BILINEAR);

must be larger than the image size. for example, if I use a sprite sheet 1200 * 100, I should use a width and height above 1200 * 100.

BitmapTextureAtlas(2047, 128, TextureOptions.BILINEAR);

+5
source

Source: https://habr.com/ru/post/1387369/


All Articles