Level Chooser

  ... discussions about development with the GLES2 branch of AndEngine.

Level Chooser

Postby Coder_For_Life22 » Sun Mar 04, 2012 4:48 am

What is the best way to go about displaying different buttons for the user to select lets say a menu of about 50 levels?

How would i place all of the buttons on the scene?

Any one have suggestions on how to do this?
User avatar
Coder_For_Life22
 
Posts: 1035
Joined: Wed Nov 09, 2011 5:37 pm

Re: Level Chooser

Postby jaym » Sun Mar 04, 2012 5:51 am

The same method is used in most mobile games.

You've got X amount of chapters, usually found in a row which can be selected via touch. Once a user selects a chapter, a grid of levels opens up, usually something like 3x5 or so. 50 levels would be a stretch to fit in one screen without it looking too cluttered.

Take a look at angry birds, stupid zombies, etc. They can give you an idea of how to layout a level select scene.
AndEngine for Android Game Development Cookbook - Based on AndEngine's latest, greatest, GLES2.0 AnchorCenter branch!
jaym
 
Posts: 690
Joined: Wed May 04, 2011 10:08 pm

Re: Level Chooser

Postby Coder_For_Life22 » Sun Mar 04, 2012 6:14 am

Thanks Jaym.

This is exactly how i would like to layout my levels. But this thing is would i have to actually place each and every level icon specifically in its location or is there a better way to place them automatically?
User avatar
Coder_For_Life22
 
Posts: 1035
Joined: Wed Nov 09, 2011 5:37 pm

Re: Level Chooser

Postby Mathew » Sun Mar 04, 2012 12:04 pm

For loop and you are done.
User avatar
Mathew
 
Posts: 1073
Joined: Sun Jul 31, 2011 2:49 pm
Location: Tarnów, Poland

Re: Level Chooser

Postby jaym » Sun Mar 04, 2012 3:57 pm

psuedo-code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. final int COLUMNS = 5;
  2. final int ROWS = 3;
  3. final int PADDING = 5;
  4.  
  5. int x = 0;
  6. int y = 0;
  7.  
  8. for(int i = 1; i <= ROWS; i++){
  9. for(int o = 1; o <= COLUMNS; o++){
  10.     Sprite tile = new Sprite(x * o, y * i, ...);
  11.  
  12.     x += tile.getWidth() + PADDING;
  13. }
  14. y += tile.getHeight() + PADDING
  15. }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
AndEngine for Android Game Development Cookbook - Based on AndEngine's latest, greatest, GLES2.0 AnchorCenter branch!
jaym
 
Posts: 690
Joined: Wed May 04, 2011 10:08 pm

Re: Level Chooser

Postby Coder_For_Life22 » Sun Mar 04, 2012 5:19 pm

Thanks jaym!

That really opened things up!
User avatar
Coder_For_Life22
 
Posts: 1035
Joined: Wed Nov 09, 2011 5:37 pm

Re: Level Chooser

Postby Coder_For_Life22 » Wed Mar 07, 2012 3:12 am

jaym quick question..How would i go about getting it to create a new row when it gets to the egde of the screen?
User avatar
Coder_For_Life22
 
Posts: 1035
Joined: Wed Nov 09, 2011 5:37 pm

Re: Level Chooser

Postby jaym » Wed Mar 07, 2012 5:37 am

you can add a if statement inside your column loop, such as:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. if(x > cameraWidth - tileWidth) break;
Parsed in 0.030 seconds, using GeSHi 1.0.8.4
AndEngine for Android Game Development Cookbook - Based on AndEngine's latest, greatest, GLES2.0 AnchorCenter branch!
jaym
 
Posts: 690
Joined: Wed May 04, 2011 10:08 pm

Re: Level Chooser

Postby Coder_For_Life22 » Wed Mar 07, 2012 2:14 pm

Thanks. one more question.

is it better to have a seperate .png file for each level icon? or is there a better way to save resources?
User avatar
Coder_For_Life22
 
Posts: 1035
Joined: Wed Nov 09, 2011 5:37 pm

Re: Level Chooser

Postby Mathew » Wed Mar 07, 2012 2:48 pm

Obviously one level icon + new Text object for number, placed on level icon, instead of loading XX images, it would be madness.
User avatar
Mathew
 
Posts: 1073
Joined: Sun Jul 31, 2011 2:49 pm
Location: Tarnów, Poland

Next

Return to GLES2

Who is online

Users browsing this forum: mavericks, Yahoo [Bot] and 43 guests