libgdx阶段和屏幕之间的区别 [英] Difference between libgdx Stage and 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
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
实例管理.与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阶段和屏幕之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!