zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    css垂直居中如何实现
    MUI顶部导航布局
    MUI底部导航栏切换效果
    Jsonp跨域问题
    【已解决】项目加载失败,Web应用程序项目XX已配置为使用IIS
    获取网站绝对路径
    css图片上加文字
    c#界面卡死处理方法
    BeginInvoke异步线程
    menustrip选项怎么设置竖向分割线
  • 原文地址:https://www.cnblogs.com/yican/p/3634858.html
Copyright © 2011-2022 走看看