libgdx Stage 和 Screen 的区别

Difference between libgdx Stage and Screen(libgdx Stage 和 Screen 的区别)

本文介绍了libgdx Stage 和 Screen 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作游戏,我在教程中看到一些人使用 Stage 类,而另一些人使用 Screen 类,但我无法弄清楚其中的区别.

I'm making a game, and I see in tutorials some people using Stage class, and others using the Screen class, but I can't figure out the diference.

推荐答案

A Stage 包含 Actor 实例并更新/动画它们并管理它们之间的命中检测.它是 scene2d场景图"API.舞台是管理要绘制的对象列表、它们在屏幕上的状态(纹理、动画状态、大小等)以及它们与用户的交互的一种方式.Libgdx 中提供的 Stage 代码主要面向按钮和列表等 UI 元素,但其核心也足够灵活,可以包含游戏元素.

A Stage holds Actor instances and updates/animates them and manages hit-detection among them. Its the root of the scene2d "scene graph" API. The Stage is one way of managing the list of objects to draw, their state on the screen (textures, animation state, size, etc), and their interactions with the user. The provided Stage code in Libgdx is mostly oriented towards UI elements like buttons and lists, but the core is flexible enough to contain game elements too.

一个Screen一般代表一个全屏用户界面页面".例如,您可能有一个主菜单"屏幕、一个选项"屏幕、一个主游戏"屏幕和一个结束积分"屏幕.Screen 实例通常由 管理游戏 实例.当与 Game 一起使用时,Screen 对象将接收标准 Libgdx 生命周期事件作为回调(pauseresumeresizerender 等).

A Screen generally represents one full-screen UI "page". For example, you might have a "Main Menu" screen, an "Options" screen, a "main game" screen and an "end credits" screen. The Screen instances are generally managed by a Game instance. When used with a Game the Screen objects will receive the standard Libgdx lifecycle events as callbacks (pause, resume, resize, render, etc).

Libgdx 中的 StageScreen 之间没有具体的关系.但最容易想到的例子是主菜单"屏幕由管理主菜单中的按钮的舞台实现.当用户点击其中一个按钮时,游戏可能会切换到主游戏画面,并释放主菜单中的一些资源.游戏画面可能使用 Stage 或可能使用原始 OpenGL 来实现游戏.

There are no concrete relationships between Stage and Screen in Libgdx. But its easiest to think of an example where the "main menu" screen is implemented by a Stage that manages the buttons in the main menu. When the user hits one of the buttons, the game might switch to the main game-play screen, and release some of the resources held by the main menu. The game-play screen might use a Stage or might use raw OpenGL to implement the game.

这篇关于libgdx Stage 和 Screen 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:libgdx Stage 和 Screen 的区别

基础教程推荐