android - When to use ShapeRenderer, Mesh + SpriteBatch, Box2D and Scene2D in Libgdx? -
i'm new in android game development , after started libgdx shaperenderer , did little more search, became confused if started right foot.
so, know when should utilize shaperenderer, mesh + spritebatch, box2d , scene2d.
libgdx has quite lot of (mostly orthogonal) apis rendering. i'm still learning way around many of them, can give overview of different parts.
shaperenderer
lets , set basic flat-colored polygons , lines on screen. not particularly efficient (it uploads lot of vertex info on each render). can quick going. oriented screen (it defaults orthographic project on total screen , units pixels).
the mesh
class gives more direct command on geometry, you're exposed lot more of details (like encoding colors floats , storing vertex data, color data, , texture info in same float array, , concept of index arrays).
the spritebatch
oriented around "sprites" (generally rectangular areas texture in them). hides of complexity (and flexibility) of texturing meshes.
box2d physics modeling, , not of other api parts mentioned (which rendering).
finally, scene2d creating animated user-interface elements buttons, lists, , sliders. powerful plenty (and has plenty neat , flexible back upwards animations , interaction events) can implement quite lot of "game" in too.
you can utilize raw "opengl" commands (see gl20
), too.
you can totally mix-and-match these different primitives (one caveat must "flush" , "end" whatever shaperenderer
/spritebatch
/mesh
render before starting different flavor). so, example, might utilize scene2d "main menu" , meta actions in game, spritebatch
render core of game, , utilize shaperenderer
generate debug overlays (think visualizing bounding boxes, etc).
also note of libgdx geared towards 2d. raw opengl
, mesh
apis can used build 3d objects.
check gdx-invaders example see how uses mesh
, opengl, , spritebatch
. (i think illustration pre-dates scene2d, there none of that...). worthwhile on implementation of these classes see they're doing underneath covers.
android libgdx box2d scene2d
No comments:
Post a Comment