久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

android 的 libGDX 動畫

libGDX animation for android(android 的 libGDX 動畫)
本文介紹了android 的 libGDX 動畫的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

如果我為桌面啟動它,它運行得非常好,但在我的 Android 導出后它在我啟動應用程序后立即崩潰.

If I start it for Desktop it runs pretty nice, but after the export for my Android it crashes right after I start the application.

所以我的問題...:

它適用于桌面但不適用于我的 Android 有什么問題?

What's wrong that it works for the Desktop but not for my Android?

public class Player implements Serializable{

/**
 * 
 */
private static final long serialVersionUID = -7913517465400462738L;

Vector2 position;
private static final int col = 4;
private static final int row = 4;
private Animation animation;
private Texture playerTexture;
private TextureRegion[] frames;
private TextureRegion currentFrame;
private float stateTime;
private int x,y, deltaX, deltaY;



public Player(Vector2 position){
    this.position = position;
    playerTexture = new Texture(Gdx.files.internal("Charackter/charackter_sprite.png"));
    TextureRegion[][] temp = TextureRegion.split(playerTexture, playerTexture.getWidth() / col, playerTexture.getHeight() / row);
    frames = new TextureRegion[col* row];

    int index = 0;
    for(int i = 0; i < row; i++){
        for(int j = 0; j < col; j++){
            frames[index++] = temp[i][j];
        }
    }
    animation = new Animation(1, frames);
    stateTime = 0;
    currentFrame = animation.getKeyFrame(0);
    deltaX = Gdx.graphics.getWidth();
    deltaY = Gdx.graphics.getHeight();
}

public void update(){

    if(stateTime < 4){
    stateTime += Gdx.graphics.getDeltaTime();
    }
    else{
        stateTime = 0;
    }       

    if (Gdx.input.isTouched())
    {
        x = Gdx.input.getX();
        y = Gdx.input.getY();
        if(x < deltaX * 50 / 100 && y > deltaY * 35 / 100 && y < deltaY * 65 / 100){
            position.x -= 1;
            currentFrame = animation.getKeyFrame(4 + stateTime);
        }
        if(x > deltaX * 50 / 100 && y > deltaY * 35 / 100 && y < deltaY * 65 / 100){
            position.x += 1;
            currentFrame = animation.getKeyFrame(8 + stateTime);
        }
        if(y < deltaY * 35 / 100 ){
            position.y += 1;
            currentFrame = animation.getKeyFrame(12 + stateTime);
        }
        if(y > deltaY * 65 / 100 ){
            position.y -= 1;
            currentFrame = animation.getKeyFrame(0 + stateTime);
        }
    }
}


public Vector2 getPosition() {
    return position;
}
public void setPosition(Vector2 position) {
    this.position = position;
}
public TextureRegion getCurrentFrame() {
    return currentFrame;
}
}

.

public class PlayScreen implements Screen {

private SpriteBatch batch;
private Vector2 position;
private Game game;
private Player player;
private Texture bild;

public PlayScreen(Game game){
    this.game = game;
}

@Override
public void render(float delta) {       
    Gdx.gl.glClearColor(1, 1, 1, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
    player.update();
    batch.begin();
    batch.draw(player.getCurrentFrame(), player.getPosition().x, player.getPosition().y);
    batch.end();
}

@Override
public void resize(int width, int height) {
    // TODO Auto-generated method stub

}

@Override
public void show() {
    batch = new SpriteBatch();
    position = new Vector2(Gdx.graphics.getWidth() / 2, Gdx.graphics.getHeight() / 2);
    player = new Player(position);
    bild = new Texture("spongebob.png");
}

@Override
public void hide() {
    // TODO Auto-generated method stub

}

@Override
public void pause() {
    // TODO Auto-generated method stub

}

@Override
public void resume() {
    // TODO Auto-generated method stub

}

@Override
public void dispose() {
    batch.dispose();

}

}

Logcat

11-25 11:25:20.990: D/dalvikvm(862): Trying to load lib /data/app-lib/com.mygdx.game.android-2/libgdx.so 0xb1caad50
11-25 11:25:21.040: D/dalvikvm(862): Added shared lib /data/app-lib/com.mygdx.game.android-2/libgdx.so 0xb1caad50
11-25 11:25:21.040: D/dalvikvm(862): No JNI_OnLoad found in /data/app-lib/com.mygdx.game.android-2/libgdx.so 0xb1caad50, skipping init
11-25 11:25:21.100: D/AndroidRuntime(862): Shutting down VM
11-25 11:25:21.100: W/dalvikvm(862): threadid=1: thread exiting with uncaught exception (group=0xb1a73d70)
11-25 11:25:21.110: E/AndroidRuntime(862): FATAL EXCEPTION: main
11-25 11:25:21.110: E/AndroidRuntime(862): Process: com.mygdx.game.android, PID: 862
11-25 11:25:21.110: E/AndroidRuntime(862): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mygdx.game.android/com.mygdx.game.android.AndroidLauncher}: com.badlogic.gdx.utils.GdxRuntimeException: Libgdx requires OpenGL ES 2.0
11-25 11:25:21.110: E/AndroidRuntime(862):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2197)
11-25 11:25:21.110: E/AndroidRuntime(862):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2258)
11-25 11:25:21.110: E/AndroidRuntime(862):  at android.app.ActivityThread.access$800(ActivityThread.java:138)
11-25 11:25:21.110: E/AndroidRuntime(862):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1209)
11-25 11:25:21.110: E/AndroidRuntime(862):  at android.os.Handler.dispatchMessage(Handler.java:102)
11-25 11:25:21.110: E/AndroidRuntime(862):  at android.os.Looper.loop(Looper.java:136)
11-25 11:25:21.110: E/AndroidRuntime(862):  at android.app.ActivityThread.main(ActivityThread.java:5026)
11-25 11:25:21.110: E/AndroidRuntime(862):  at java.lang.reflect.Method.invokeNative(Native Method)
11-25 11:25:21.110: E/AndroidRuntime(862):  at java.lang.reflect.Method.invoke(Method.java:515)
11-25 11:25:21.110: E/AndroidRuntime(862):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
11-25 11:25:21.110: E/AndroidRuntime(862):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
11-25 11:25:21.110: E/AndroidRuntime(862):  at dalvik.system.NativeStart.main(Native Method)
11-25 11:25:21.110: E/AndroidRuntime(862): Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Libgdx requires OpenGL ES 2.0
11-25 11:25:21.110: E/AndroidRuntime(862):  at com.badlogic.gdx.backends.android.AndroidGraphics.createGLSurfaceView(AndroidGraphics.java:122)
11-25 11:25:21.110: E/AndroidRuntime(862):  at com.badlogic.gdx.backends.android.AndroidGraphics.<init>(AndroidGraphics.java:102)
11-25 11:25:21.110: E/AndroidRuntime(862):  at com.badlogic.gdx.backends.android.AndroidGraphics.<init>(AndroidGraphics.java:95)
11-25 11:25:21.110: E/AndroidRuntime(862):  at com.badlogic.gdx.backends.android.AndroidApplication.init(AndroidApplication.java:133)
11-25 11:25:21.110: E/AndroidRuntime(862):  at com.badlogic.gdx.backends.android.AndroidApplication.initialize(AndroidApplication.java:99)
11-25 11:25:21.110: E/AndroidRuntime(862):  at com.mygdx.game.android.AndroidLauncher.onCreate(AndroidLauncher.java:14)
11-25 11:25:21.110: E/AndroidRuntime(862):  at android.app.Activity.performCreate(Activity.java:5242)
11-25 11:25:21.110: E/AndroidRuntime(862):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
11-25 11:25:21.110: E/AndroidRuntime(862):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2161)
11-25 11:25:21.110: E/AndroidRuntime(862):  ... 11 more

我是 Java 新手所以我希望這是正確的部分:x

I'm pretty new in Java so I hope it's the right part :x

推薦答案

已經有一些人出現異常,logcat 說:

There has been some persons with exceptions where the logcat says:

GdxRuntimeException: Libgdx requires OpenGL ES 2.0   

這是由于您的模擬器沒有使用您的 gpu 進行圖形處理,最好的解決方案是使用您的手機測試您的應用程序,但如果由于任何原因您不能,您可以像 @AngelAngel 一樣應用此解決方案:libgdx android 啟動失敗.
出于某種原因(可能是opengl沒有出現故障)以下錯誤的解決方案也可能對您有所幫助

This is due to your emulator not using your gpu for graphics and the best solution would be to use your phone to test your application but if for any reason you can't you can as @AngelAngel apply this solution: libgdx android failed on launch.
For some reason ( probably the opengl not glitching ) the solution to the following error might also help you

 com.badlogic.gdx.utils.GdxRuntimeException: Error reading file: xxx.xxx

如果您僅在 Android 上進行試驗而在 Windows 上運行時遇到此錯誤,則可能是因為您的資產之一與您在代碼中使用的名稱不完全匹配.Unix 區分大小寫,因此 image.jpg 與 Image.jpg 不同.所以檢查你必須的每一個資產,看看名字是否匹配!

If you have this error only while experimenting in Android while it works on Windows it probably is because one of your assets doesn't exactly match the name you used on your code. Unix is case-sensative so image.jpg is different from Image.jpg . So check every asset you have to see if the names match!

這篇關于android 的 libGDX 動畫的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 国产原创在线观看 | 国产羞羞视频在线观看 | 美女久久久久久久久 | 国产欧美在线观看 | 艹逼网| 久久伊人影院 | 国产午夜在线 | 怡红院免费的全部视频 | 日韩成人在线播放 | 欧美日韩精品一区二区三区四区 | 亚洲视频手机在线 | 91婷婷韩国欧美一区二区 | 亚洲影视在线 | 香蕉久久av | 亚洲一区成人 | 亚洲伊人a | 国产97视频在线观看 | 欧美网址在线观看 | 久久婷婷国产香蕉 | 欧美不卡一区二区三区 | 国产成人网| 精品久久久久久久久久久久 | 亚洲精品在线免费观看视频 | 伊人av在线播放 | 精品欧美一区二区三区久久久 | 国产高清视频 | 国产精品明星裸体写真集 | 免费一区二区三区 | 亚洲精品久久久久久久不卡四虎 | 国产高清精品网站 | 国产精品久久久久一区二区 | 九一视频在线观看 | 国产午夜精品一区二区三区嫩草 | 在线观看深夜视频 | av免费网站在线观看 | 欧美久久不卡 | 亚洲一区二区三区 | 另类 综合 日韩 欧美 亚洲 | 久久久高清 | 一区二区精品 | 欧美一区二区视频 |