问题描述
我只是在遍历有关libgdx的javadoc和各种教程,并且正处于试图弄清似乎与我相似或在libgdx中提供类似功能的各种概念之间的差异的阶段.
I'm just going through the javadoc and various tutorials on libgdx and I'm at the stage of trying to figure out differences between various concepts that seem similar to me or provide similar capabilities in libgdx.
起初,我以为scene2d是关于创建交互式项目(例如菜单等)的,但是我正在阅读的各种教程都将scene2d/actor用于主要游戏项目(例如,玩家等),而其他教程则仅使用精灵.
At first I thought scene2d was about creating interactive items such as menus, etc but various tutorials I'm reading use scene2d/actors for the main game items (i.e. the player, etc) and others just use sprites.
在游戏中使用Sprite和Actor(即Scene2D)到底有什么区别,什么时候应该选择?
What exactly is the difference between using Sprite and Actor (i.e. scene2D) in a game and when should you choose?
谢谢.
推荐答案
Sprite
本质上是具有位置,大小和旋转度的图像.您可以使用 SpriteBatch
,一旦有了Sprite
和SpriteBatch
,便有了一种简单的低级方法,可以在屏幕上的任意位置获取2D图像.其余的取决于您.
但是请注意,Actor
不像Sprite
那样包含纹理.相反,您可能想使用 ,它是Actor
的子类,它可能比普通的Actor
更接近Sprite
. Actor
的其他子类包含文本,依此类推.
But note that Actor
does not contain a texture like Sprite
does. Instead you probably want to use Image
, a subclass of Actor
that's probably closer to Sprite
than just a plain Actor
. Other subclasses of Actor
contain text, and so on.
Actor
的另一个大优点是它们可以具有Action
个.这些是大话题,但实际上,它们允许您为该Actor
计划一系列事件(例如淡入,移动等),一旦设置它们,它们就会自行发生.
Another big advantage of Actor
s is that they can have Action
s. These are a big topic, but they essentially allow you to plan a sequence of events for that Actor
(like fading in, moving, etc) that will then happen on their own once you set them.
因此,基本上Actor
比Sprite
的功能要多得多,因为它是图形框架的一部分.
So basically Actor
does a lot more than Sprite
because it's part of a graphical framework.
这篇关于sprite和actor之间的libgdx区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!