Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
LibGDX拼接纹理文件_Libgdx_Textures - Fatal编程技术网

LibGDX拼接纹理文件

LibGDX拼接纹理文件,libgdx,textures,Libgdx,Textures,我有一个图像,它由块(32*32)组成,有1行4列。当我加载一个纹理时,我只能加载一个块而不是全部4个块,我该怎么做呢?方法1) 方法2) 是否要在内存中仅加载此特定块,或仅将此特定块用作精灵中的纹理?用作使用精灵批渲染的纹理。 Texture texture=new Texture(Gdx.files.internal("ui/logo2.png")); Sprite sprite=new Sprite(texture); sprite.setRegion(0, 0,

我有一个图像,它由块(32*32)组成,有1行4列。当我加载一个纹理时,我只能加载一个块而不是全部4个块,我该怎么做呢?

方法1)

方法2)


是否要在内存中仅加载此特定块,或仅将此特定块用作精灵中的纹理?用作使用精灵批渲染的纹理。
    Texture texture=new Texture(Gdx.files.internal("ui/logo2.png"));
    Sprite sprite=new Sprite(texture);
    sprite.setRegion(0, 0, 1f/4f, 1);//this loads the first block
    sprite.setRegion(1f/4f, 0, 1f/4f+1f/4f, 1);//this loads the second block
    sprite.setRegion((1f/4f)*2, 0, 1f/4f+(1f/4f)*2, 1);//this loads the third block
    //on render
    sprite.draw(theSpriteBatch);   
    Texture texture=new Texture(Gdx.files.internal("ui/logo2.png"));
    TextureRegion[][] tmp = TextureRegion.split(texture, 32, 32);
    Sprite sprite=new Sprite(tmp[0][0]);//first
    Sprite sprite=new Sprite(tmp[0][1]);//second
    Sprite sprite=new Sprite(tmp[0][2]);//third
    //on render
    sprite.draw(yourSpriteBatch);