找到你要的答案

Q:Whats the best way to make collidable objects without Tile2D?

Q:让collidable对象没有tile2d最佳的方式是什么?

I'm currently trying to make a small platformer, but don't want to use Tile2D (specific reasons), what should I use instead to make platforms (objects the player can collide with).

At the moment, I have a List with every Rectangle the player can collide with and I go through every Rectangle when I want to check collisions, but I find that to be very clunky.

What should I use to make platforms, the player etc. I haven't used Box2D yet, dont know if its the thing I need and am also not sure wether Scene2D is the thing I am looking for. Any tips would be appreciated. Not sure if this is the right place to post this, but its worth a try.

我现在想做一个小游戏,但不想用tile2d(具体原因),我应该用什么来做平台(玩家可以与物体相撞)。

此刻,我有一个列表,每个矩形的球员可以碰撞和我穿过每一矩形时,我要检查的碰撞,但我发现这是非常笨拙的。

我应该用什么来做平台,玩家等我没有使用Box2D呢,不知道的是我所需要的东西,我也不知道scene2d是我在寻找的东西。任何提示将不胜感激。不知道这是不是正确的地方张贴,但它值得一试。

answer1: 回答1:

Don't mix two things:

  • Box2D is a physics engine that allows you to simulate physical world with its whole actions like collisions handling, applying forces or velocity etc
  • Scene2D is a framework to "clean up" handling objects you want to manage - by definition it is scene graph that allows you to treat bunches of objects as single objects (groups) and apply for them some actions (like setting position on the screen)

So basically when Box2D is more about how objects will behave themselves during application running the Scene2D is more about how you write your code before application running.

Of course Scene2D is very helpful if you want to implement your own mechanism of collisions (like you wrote - you have rectangles array, then iterate over them and check their positions... etc) but the Box2D deliveres you this mechanism so you don't have to do nothing to check just tell the application what to do when collision will occurs.

Then it is problem about is it worth to implement your own collisions mechanism. The most frequent answer I guess is - if the game is simple and the mechanism will be then yes. If not just use physics engine - do not invent fire again ;)

To read about Box2D and learn how to use it visit:

To read about Scene2D:

不要混淆两件事:

  • Box2D is a physics engine that allows you to simulate physical world with its whole actions like collisions handling, applying forces or velocity etc
  • Scene2D is a framework to "clean up" handling objects you want to manage - by definition it is scene graph that allows you to treat bunches of objects as single objects (groups) and apply for them some actions (like setting position on the screen)

所以当Box2D是更多关于对象将如何表现自己的应用运行在scene2d更多是关于你如何写你的代码之前运行的应用。

当然scene2d很有帮助,如果你想实现你自己的机制碰撞(像你写的-你有矩形数组,然后遍历它们,检查它们的位置…等)但Box2D使得你这机制,所以你不需要做什么检查只是告诉应用程序做什么时,会发生碰撞。

那么它的问题是值得实现自己的碰撞机制。最常见的答案,我猜是-如果游戏是简单的机制将是。如果不只是使用物理引擎-不要再发明火;

阅读关于Box2D和学习如何使用它访问:

阅读关于scene2d:

libgdx