本文介绍了“游戏”,“屏幕”和“屏幕”之间的区别是什么?和“ApplicationAdapter”在libgdx?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在教程中,有时人们使用extends Game,有时候实现Screen,我自动生成extends ApplicationAdapter。它们之间有什么区别?

In tutorials sometimes people use "extends Game", sometimes "implements Screen" and i have auto-generated "extends ApplicationAdapter". What is the difference between them?

推荐答案

ApplicationAdapter 允许您创建一个监听器,但不是被迫实现每个方法。如果您熟悉Swing,请查看 KeyAdapter ,这是一样的想法。

ApplicationAdapter allows you to create a listener, but not being forced to implement every method. If you're familiar with Swing, check out KeyAdapter, it's the same idea.

一个 ApplicationListener 允许您处理应用程序事件。这允许您在应用程序生命周期内的某些事件期间执行代码(例如destroy)。

An ApplicationListener allows you to handle application events. This allows you to execute code during certain events within the application life-cycle (such as destroy).

A 游戏是一个支持多个屏幕的 ApplicationListener 。您可以使用 setScreen 创建多个屏幕并在em之间切换。

A Game is an ApplicationListener that supports multiple screens. You can create multiple screens and switch between em using setScreen.

A 屏幕正是如此它听起来像什么;这是在给定时间显示的内容。也许它是一个主菜单,也许它就是真正的游戏。

A Screen is exactly what it sounds like; it's what will be displayed at that given time. Maybe it's a main menu, maybe it's the actual game.

建议你使用游戏为您的游戏基础提供课程,然后创建多个屏幕您将拥有的不同游戏状态的实例。

It's recommended you use the Game class for the base of your game, then create multiple Screen instances of the different possible game states you will have.

这篇关于“游戏”,“屏幕”和“屏幕”之间的区别是什么?和“ApplicationAdapter”在libgdx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-17 21:45
查看更多