Difference between libgdx Stage and 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 生命周期事件作为回调(pause
、resume
、resize
、render
等).
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 中的 Stage
和 Screen
之间没有具体的关系.但最容易想到的例子是主菜单"屏幕由管理主菜单中的按钮的舞台实现.当用户点击其中一个按钮时,游戏可能会切换到主游戏画面,并释放主菜单中的一些资源.游戏画面可能使用 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 的区别
基础教程推荐
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01