• Starter Classes of Libgdx


    A Starter Class defines the entry point (starting point) of a Libgdx application,Starter Class定义libgdx应用的的进入口

    Once booting has finished, the
    Libgdx framework hands over control from the Starter Class (for example, the
    demo-desktop project) to your shared application code (for example, the demo
    project) by calling the different methods from the ApplicationListener interface
    that the MyDemo class implements(英文原文)

    一旦启动完成,libgdx框架就会将控制权从启动类转移给你的共享代码区,也就是核心代码区,其中的原理就是调用ApplicationListener接口中的各种方法,下面让我们来看代码

    下面给出demo-desktop中的Main.java

    package com.packtpub.libgdx.demo;
    import com.badlogic.gdx.backends.lwjgl.LwjglApplication;
    import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration;
    public class Main {
    public static void main(String[] args) {
    LwjglApplicationConfiguration cfg =
    new LwjglApplicationConfiguration();
    cfg.title = "demo";
    cfg.useGL20 = false;
    cfg.width = 480;
    cfg.height = 320;
    new LwjglApplication(new MyDemo(), cfg);
    }
    }
    new LwjglApplication(new MyDemo(), cfg);中传入的第一个参数为LwjglApplication实例,MyDemo实现了
    LwjglApplication,第二个参数为LwjglApplicationConfiguration的实例。
    运行后得到如下画面

    下面给出demo-android中的MainActivity.java

    package com.packtpub.libgdx.demo;
    import android.os.Bundle;
    import com.badlogic.gdx.backends.android.AndroidApplication;
    import com.badlogic.gdx.backends.android
    .AndroidApplicationConfiguration;
    public class MainActivity extends AndroidApplication {
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AndroidApplicationConfiguration cfg =
    new AndroidApplicationConfiguration();
    cfg.useGL20 = false;
    initialize(new MyDemo(), cfg);
    }
    }

    it is an instance of the MyDemo class. The instances of MyDemo
    and AndroidApplicationConfiguration are passed as arguments to the
    initialize() method. The configuration is set to not request OpenGL ES 2.0
    support on an Android device.

  • 相关阅读:
    Coxph model Pvalue Select2
    Coxph model Pvalue Select
    WGCNA 分析
    Python 识别验证码
    Python2.X如何将Unicode中文字符串转换成 string字符串
    客户端putty xshell连接linux中vim不能正常使用小键盘的问题
    解决Selenium Webdriver执行测试时,每个测试方法都打开一个浏览器窗口的问题
    在Windows上,迁移VisualSVN server
    testNG设置测试的执行顺序
    重新加载maven项目的依赖项
  • 原文地址:https://www.cnblogs.com/yican/p/3634858.html
Copyright © 2020-2023  润新知