Итак, MenuScreen работает нормально, но я не могу понять, почему я получаю эту ошибку.Это происходит в начале настоящей игры после нажатия кнопки «Пуск» в меню «Пуск».
public class NinjaRabbitGraphicsProcessor implements GraphicsProcessor, Telegraph {
private static final String WALK_REGION = "walk";
private static final String JUMP_REGION = "jump";
// private static final String DUCK_REGION = "duck";
private static final Vector2 RESPAWN_POSITION = new Vector2(0.6f, 3.2f);
private final TextureAtlas textureAtlas;
private final Box2DSprite standingSprite;
private final AnimatedBox2DSprite walkRightSprite;
private final AnimatedBox2DSprite walkLeftSprite;
private final AnimatedBox2DSprite jumpSprite;
// private final AnimatedBox2DSprite duckSprite;
public NinjaRabbitGraphicsProcessor(final AssetManager assets) {
textureAtlas = assets.get(Assets.NINJA_RABBIT_ATLAS);
Array<Sprite> walkingSprites = textureAtlas.createSprites(WALK_REGION);
standingSprite = new Box2DSprite(walkingSprites.first());
standingSprite.setAdjustSize(false);
standingSprite.setSize(standingSprite.getWidth() / NinjaRabbitGame.PPM,
standingSprite.getHeight() / NinjaRabbitGame.PPM);
Animation animation = new Animation(1 / 12.0f, walkingSprites, Animation.PlayMode.LOOP);
walkRightSprite = new AnimatedBox2DSprite(new AnimatedSprite(animation));
walkRightSprite.setAdjustSize(false);
walkRightSprite.setSize(walkRightSprite.getWidth() / NinjaRabbitGame.PPM,
walkRightSprite.getHeight() / NinjaRabbitGame.PPM);
animation = new Animation(1 / 12.0f, textureAtlas.createSprites(WALK_REGION), Animation.PlayMode.LOOP);
walkLeftSprite = new AnimatedBox2DSprite(new AnimatedSprite(animation));
walkLeftSprite.flipFrames(true, false, true);
walkLeftSprite.setAdjustSize(false);
walkLeftSprite.setSize(walkLeftSprite.getWidth() / NinjaRabbitGame.PPM,
walkLeftSprite.getHeight() / NinjaRabbitGame.PPM);
animation = new Animation(1 / 10.0f, textureAtlas.createSprites(JUMP_REGION));
jumpSprite = new AnimatedBox2DSprite(new AnimatedSprite(animation));
jumpSprite.setAdjustSize(false);
jumpSprite.setSize(jumpSprite.getWidth() / NinjaRabbitGame.PPM,
jumpSprite.getHeight() / NinjaRabbitGame.PPM);
MessageManager.getInstance().addListener(this, MessageType.DEAD.code());
}
/*
* (non-Javadoc)
*
* @see ar.uba.fi.game.graphics.GraphicsProcessor#update(ar.uba.fi.game.entity.Entity,
* com.badlogic.gdx.graphics.Camera)
*/
@Override
public void update(final Entity character, final Camera camera) {
camera.position.x = character.getBody() == null ? 0.0f :
character.getBody().getPosition().x + camera.viewportWidth * 0.25f;
}
/*
* (non-Javadoc)
*
* @see ar.uba.fi.game.entity.GraphicsProcessor#draw(com.badlogic.gdx.graphics.g2d.Batch)
*/
@Override
public void draw(final Entity character, final Batch batch) {
Box2DSprite frame = null;
if (character.isInState(NinjaRabbitState.JUMP)) {
jumpSprite.flipFrames(!(Direction.RIGHT.equals(character.getDirection()) ^ jumpSprite.isFlipX()), false, false);
frame = jumpSprite;
} else if (character.isInState(NinjaRabbitState.RIGHT)) {
frame = walkRightSprite;
character.setDirection(Direction.RIGHT);
} else if (character.isInState(NinjaRabbitState.LEFT)) {
frame = walkLeftSprite;
character.setDirection(Direction.LEFT);
} else if (character.isInState(NinjaRabbitState.DUCK)) {
// frame = duckSprite;
} else {
standingSprite.flip(!(Direction.RIGHT.equals(character.getDirection()) ^ standingSprite.isFlipX()), false);
frame = standingSprite;
// duckSprite.setTime(0.0f);
jumpSprite.setTime(0.0f);
}
// Following numbers came from voodoo
frame.setPosition(
-frame.getWidth() * 0.5f +
Box2DUtils.width(character.getBody()) / (Direction.RIGHT.equals(character.getDirection())
? 2.8f : 1.55f),
-frame.getHeight() * 0.5f + Box2DUtils.width(character.getBody()) + 0.36f);
frame.draw(batch, character.getBody());
}
@Override
public boolean handleMessage(final Telegram msg) {
Entity character = (Entity) msg.extraInfo;
character.getBody().setTransform(RESPAWN_POSITION, character.getBody().getAngle());
character.changeState(NinjaRabbitState.IDLE);
character.setDirection(Direction.RIGHT);
return true;
}
@Override
public void dispose() {
}
@Override
public void resize(final int width, final int height) {
}
}
У меня явно нет ошибок во время компиляциипоэтому я не могу найти, где это должно быть.
Помощь очень ценится.Пожалуйста, уточните.
РЕПО