1

I am using LibGdx to develop a game. For Now I am not using scene2D. I am struck up in increasing the levels of the game as I do not have the scrolling screen.

I like to design a a scrolling screen as it is in many games which are level based (for ref, lets say Candy crush). Could you please point me a example on how to have such a scrolling screen to show a bigger area where I can show many levels.

Thanks is Advance !

iappmaker
  • 2,945
  • 9
  • 35
  • 76

1 Answers1

2

Using the Scene2D function is not necessary for this and is more for GUI implementation and different screens. The Scroll pane really shines when creating reading content that does not fit your phone. I do advice to start learning Scene2D to create MenuScreens and UI though.

What Candy Crush "simply" does is having multiple backgrounds that are placed next to each other and tile seamlessly. They use buttons in the correct place for levels. By dragging a finger across the screen the camera will move in that direction. For the movement from one level to the next there is probably something like a spline in play.

It is important only to draw the background tiles and buttons that are actually visible on the screen if you have many. Since these have fixed positions and you know your camera area and position you can calculate what to draw and what not. Just drawing everything each frame is likely to slow down your fps.

You can do a search on:

  • Tilemaps, for you backgrounds but you probably want them in just one direction so a simple 1D array would suffice.
  • Dragging, to move your camera. Here I gave a basic explanations on how I do it.
  • Splines, are a bit tougher and you do not really need them. They could be used to animate or move something along a curve.

Thats all, expecting you know how to create something like a button (click a sprite).

Community
  • 1
  • 1
Madmenyo
  • 8,389
  • 7
  • 52
  • 99
  • Menno, I am trying to work with the answer you have given in the 2nd bullet "Dragging" with 3 different screen tiled together. At any point of time I need to check if my camera is moving out of the actuall area to avoid showing the black screen. Is there is any way I can get the coordinates of the current viewport so that i can use it to check the boundary condition – iappmaker Jun 19 '15 at 03:38
  • "Dragging" is not smooth. Any idea how to make this smooth. I hope this can be done using the Gesture concepts. Advice plz – iappmaker Jun 19 '15 at 07:02
  • I did it with fling action. It is perfect now. Thanks – iappmaker Jun 19 '15 at 15:32
  • Went offline after my post. Good to hear you fixed it yourself. – Madmenyo Jun 19 '15 at 17:39