libgdx阶段和屏幕之间的区别 [英] Difference between libgdx Stage and Screen

查看:93
本文介绍了libgdx阶段和屏幕之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个游戏,我在教程中看到有些人使用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 实例并对其进行更新/动画处理,并管理其中的命中检测.它是 scene2d场景图" API .舞台是一种管理绘制对象列表,它们在屏幕上的状态(纹理,动画状态,大小等)以及它们与用户的交互的一种方法. Libgdx中提供的舞台代码主要面向按钮和列表等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 实例管理.与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阶段和屏幕之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆