libgdx The application frame working

本文档详尽地介绍了LibGDX游戏开发框架的各项功能与使用方法,包括但不限于项目搭建、第三方服务集成、图形渲染、音频处理等核心模块。通过实际代码示例展示了如何根据运行平台的不同调整应用行为,并提供了查询应用程序内存占用的方法。

Table of Contents

a note from the translation

Wiki Style Guide

The Application interface provides various methods to query properties of the run-time environment.

Getting the Application Type 获取游戏运行的平台类型

Sometimes it is necessary to special case specific parts of an application depending on the platform it is running on. The Application.getType() method returns the platform the application is currently running on:

switch (Gdx.app.getType()) {
    case Android:
        // android specific code
        break;
    case Desktop:
        // desktop specific code
        break;
    case WebGl:
        // HTML5 specific code
        break;
    default:
        // Other platforms specific code
}

On Android, one can also query the Android version the application is currently running on:

int androidVersion = Gdx.app.getVersion();

This will return the SDK level supported on the current device, e.g. 3 for Android 1.5.

Memory Consumption 查询游戏运行时占用内存的状况

For debugging and profiling purposes it is often necessary to know the memory consumption, for both the Java heap and the native heap:

long javaHeap = Gdx.app.getJavaHeap();
long nativeHeap = Gdx.app.getNativeHeap();

Both methods return the number of bytes currently in use on the respective heap.


demo:

package com.example.groupactiontest;

import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;

public class MyGame implements ApplicationListener {

	
	@Override
	public void create() {
		switch (Gdx.app.getType()) {//获取libgdx游戏所运行的平台
		case Android:
			System.out.println("--------->你现在用的是android设备...");
			break;
		case Desktop:
			
			break;
		case WebGL:
			break;
		default:
			
		}
		
		int androidVersion = Gdx.app.getVersion();//获取你的android设备的SDK版本所对应的API level
		System.out.println("运行所运行的游戏的平台是: " + androidVersion);
	    
		//对本app占用内存的状况的查询
		long javaHeap = Gdx.app.getJavaHeap();//获取javaheap
		long nativeHeap = Gdx.app.getNativeHeap();//获取本地heap
		
		System.out.println( "javaHeap: "+ javaHeap);
		System.out.println( "nativeHeap: "+ nativeHeap);
	}

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

	}

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

	}

	@Override
	public void render() {
		Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
	}

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

	}

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

	}

}

下载链接:

http://download.youkuaiyun.com/detail/caihongshijie6/7035857

基于可靠性评估序贯蒙特卡洛模拟法的配电网可靠性评估研究(Matlab代码实现)内容概要:本文围绕基于序贯蒙特卡洛模拟法的配电网可靠性评估展开研究,重点介绍了利用Matlab代码实现该方法的技术路径。文中详细阐述了序贯蒙特卡洛模拟的基本原理及其在配电网可靠性分析中的应用,包括系统状态抽样、时序模拟、故障判断与修复过程等核心环节。通过构建典型配电网模型,结合元件故障率、修复时间等参数进行大量仿真,获取系统可靠性指标如停电频率、停电持续时间等,进而评估不同运行条件或规划方案下的配电网可靠性水平。研究还可能涉及对含分布式电源、储能等新型元件的复杂配电网的适应性分析,展示了该方法在现代电力系统评估中的实用性与扩展性。; 适合人群:具备电力系统基础知识和Matlab编程能力的高校研究生、科研人员及从事电网规划与运行的技术工程师。; 使用场景及目标:①用于教学与科研中理解蒙特卡洛模拟在电力系统可靠性评估中的具体实现;②为实际配电网的可靠性优化设计、设备配置与运维策略制定提供仿真工具支持;③支撑学术论文复现与算法改进研究; 阅读建议:建议读者结合提供的Matlab代码逐段理解算法流程,重点关注状态转移逻辑与时间序列模拟的实现细节,并尝试在IEEE标准测试系统上进行验证与扩展实验,以深化对方法机理的理解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值