gpt4 book ai didi

java - TextureRegion.split Android工作室错误

转载 作者:行者123 更新时间:2023-11-30 00:12:03 25 4
gpt4 key购买 nike

我收到此错误:“无法为行解析符号‘split’”

    rollSpriteSheet = new  TextureRegion.split(new Texture("ship.png"),Constants.SHIP_WIDTH_PIXEL,Constants.SHIP_HEIGHT_PIXEL);

我也声明了 TextureRegion,在 Message Gradle Build 中我得到:

Error:(35, 45) error: cannot find symbol class split

这是我的代码:

public class ShapexScreen extends InputAdapter implements Screen {
public static final String TAG = ShapexScreen.class.getName();
float x;
float y;
Animation[] rolls;
TextureRegion[][] rollSpriteSheet;
int roll;
float stateTime; //statetime is adding delta time every frame
Foflex game;

public ShapexScreen(Foflex game){
this.game = game;
y = 15;
x = Constants.SCREEN_WIDTH /2 - Constants.SCREEN_WIDTH /2;
roll = 2; //roll 2 would be in middle
rolls = new Animation[5]; //Five different roll states
rollSpriteSheet = new TextureRegion.split(new Texture("ship.png"),Constants.SHIP_WIDTH_PIXEL,Constants.SHIP_HEIGHT_PIXEL); //2d array to store the ship sprite sheet
rolls[roll] = new Animation(Constants.ANIMATION_SPEED, rollSpriteSheet[0]);
}

最佳答案

TextureRegion

Defines a rectangular area of a texture. The coordinate system used has its origin in the upper left corner with the x-axis pointing to the right and the y axis pointing downwards.

Error:(35, 45) error: cannot find symbol class split

你应该这样调用

rollSpriteSheet = TextureRegion.split(new Texture("ship.png"),Constants.SHIP_WIDTH_PIXEL,Constants.SHIP_HEIGHT_PIXEL); 

仅供引用

public TextureRegion[][] split(int tileWidth,
int tileHeight)

Helper function to create tiles out of this TextureRegion starting from the top left corner going to the right and ending at the bottom right corner. Only complete tiles will be returned so if the region's width or height are not a multiple of the tile width and height not all of the region will be used. This will not work on texture regions returned form a TextureAtlas that either have whitespace removed or where flipped before the region is split.

关于java - TextureRegion.split Android工作室错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48002280/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com