У меня проблема с определенной строкой, когда я пытаюсь установить playmode для анимации.Проблема с анимацией libgdx
По this API У меня есть следующие возможности:
- LOOP
- LOOP_PINGPONG
- LOOP_RANDOM
- LOOP_REVERSED
- NORMAL
- ПЕРЕВЕРНУТЫМ
Однако, при выполнении:
import com.badlogic.gdx.graphics.g2d.Animation;
...
spriteAnimation.setPlayMode(Animation.LOOP_PINGPONG);
я LOOP_PINGPONG cannot be resolved or is not a field
. Какова причина этого? Как я вижу, это заявлено как выполнимое в API?
Edit:
Я должен заявить, что я после guide для игростроения с libgdx. Но гиду больше года, поэтому я не могу найти там большой помощи.
package com.guldbechnielsensolutions.gamehelpers;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Preferences;
import com.badlogic.gdx.graphics.g2d.Animation.PlayMode;
import com.badlogic.gdx.audio.Sound;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
public class AssetLoader {
public static Preferences prefs;
public static Texture texture;
public static TextureRegion bg, grass;
public static Animation spriteAnimation;
public static TextureRegion sprite, spriteDown, spriteUp;
public static TextureRegion skullUp, skullDown, bar;
public static Sound dead, flap, coin;
public static BitmapFont font, shadow;
public static void load() {
texture = new Texture(Gdx.files.internal("data/texture.png"));
texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);
bg = new TextureRegion(texture, 0, 0, 136, 43);
bg.flip(false, true);
grass = new TextureRegion(texture, 0, 43, 143, 11);
grass.flip(false, true);
spriteDown = new TextureRegion(texture, 136, 0, 17, 12);
spriteDown.flip(false, true);
sprite = new TextureRegion(texture, 153, 0, 17, 12);
sprite.flip(false, true);
spriteUp = new TextureRegion(texture, 170, 0, 17, 12);
spriteUp.flip(false, true);
TextureRegion[] sprites = { spriteDown, sprite, spriteUp };
spriteAnimation = new Animation(0.06f, sprites);
spriteAnimation.setPlayMode(Animation.LOOP_PINGPONG);
skullUp = new TextureRegion(texture, 192, 0, 24, 14);
// Create by flipping existing skullUp
skullDown = new TextureRegion(skullUp);
skullDown.flip(false, true);
bar = new TextureRegion(texture, 136, 16, 22, 3);
bar.flip(false, true);
dead = Gdx.audio.newSound(Gdx.files.internal("data/dead.wav"));
flap = Gdx.audio.newSound(Gdx.files.internal("data/flap.wav"));
coin = Gdx.audio.newSound(Gdx.files.internal("data/coin.wav"));
font = new BitmapFont(Gdx.files.internal("data/text.fnt"));
font.getData().setScale(.25f, -.25f);
shadow = new BitmapFont(Gdx.files.internal("data/shadow.fnt"));
shadow.getData().setScale(.25f, -.25f);
prefs = Gdx.app.getPreferences("Get Me Out");
if (!prefs.contains("highScore")) {
prefs.putInteger("highScore", 0);
}
}
public static void setHighScore(int val) {
prefs.putInteger("highScore", val);
prefs.flush();
}
public static int getHighScore() {
return prefs.getInteger("highScore");
}
public static void dispose() {
// We must dispose of the texture when we are finished.
texture.dispose();
// Dispose sounds
dead.dispose();
flap.dispose();
coin.dispose();
font.dispose();
shadow.dispose();
}
}
Пожалуйста, добавьте еще какой-нибудь код, чтобы мы могли точно видеть, что происходит – frgnvola
Конечно, я отправлю класс. – Evilunclebill