Advanced Menus

  ... the case you feel the need for a new feature or want to submit one.

Advanced Menus

Postby methodin » Mon Jun 13, 2011 1:42 am

Hey all,

Recently finished hacking together the first version of a Menu class (and sibling Animator class) to provide a more advanced/flexible menu system than the ones provided by default in Andengine.

Source can be found @ https://github.com/methodin/Andengine-Plugins/tree/master/CustomMenu

Example can be found @ http://www.andengine.org/forums/development/dynamic-menu-classes-available-soon-t3579.html

Will be adding some more advanced capabilities in a bit but its a good start :P
Check out my FREE game Particly
http://particly.com
methodin
 
Posts: 52
Joined: Wed Apr 20, 2011 3:07 am

Re: Advanced Menus

Postby oeN » Mon Jun 13, 2011 7:47 pm

I've tested your code as works ok, But if I add more items than those that can be display the items become invisible. Is it possible to add a horizontal/vertical scroll option and a auto br option so if an item can't be displayed on screen it would be automatically add a break.

thanks
Blog: link
My Android Apps: link
oeN
 
Posts: 15
Joined: Wed Jun 08, 2011 8:21 pm

Re: Advanced Menus

Postby najhi » Sat Mar 31, 2012 9:44 am

hello

i am using menu example and want to show its reset and quit bottom with your advanced custom menu. but when i add these buttons to custom menu my application crashes with a null Pointer Exception. i don't know why it is doing this. please help me. :( as i am new to andEngine.

my code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. protected void createMenuScene() {
  2.                 this.mMenuScene = new CustomMenuScene(this.mCamera);
  3.                
  4.                
  5.                 final SpriteMenuItem nextMenuItem = new SpriteMenuItem(MENU_RESET, this.mMenuResetTextureRegion);
  6.                 nextMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
  7.                
  8.                 final SpriteMenuItem resetMenuItem = new SpriteMenuItem(MENU_QUIT, this.mMenuQuitTextureRegion);
  9.                 resetMenuItem.setBlendFunction(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA);
  10.                
  11.                 this.mMenuScene
  12.                         .add(nextMenuItem)
  13.                         .add(resetMenuItem)
  14.                         .br();
  15.                
  16.                 mMenuScene.setMenuAnimator(new CustomMenuAnimator(5.0f));
  17.  
  18.                 this.mMenuScene.buildAnimations();
  19.                 this.mMenuScene.setBackgroundEnabled(false);
  20.                 this.mMenuScene.setOnMenuItemClickListener(this);
  21.         }
Parsed in 0.012 seconds, using GeSHi 1.0.8.4


Error i get:

03-31 22:46:04.612: E/AndroidRuntime(6806): FATAL EXCEPTION: main
03-31 22:46:04.612: E/AndroidRuntime(6806): java.lang.NullPointerException
03-31 22:46:04.612: E/AndroidRuntime(6806): at com.najhi.andengine.CustomMenuScene.add(CustomMenuScene.java:149)
03-31 22:46:04.612: E/AndroidRuntime(6806): at com.najhi.andengine.MenuExample.createMenuScene(MenuExample.java:203)
03-31 22:46:04.612: E/AndroidRuntime(6806): at com.najhi.andengine.MenuExample.onLoadScene(MenuExample.java:100)
03-31 22:46:04.612: E/AndroidRuntime(6806): at org.anddev.andengine.ui.activity.BaseGameActivity.doResume(BaseGameActivity.java:169)
03-31 22:46:04.612: E/AndroidRuntime(6806): at org.anddev.andengine.ui.activity.BaseGameActivity.onWindowFocusChanged(BaseGameActivity.java:85)
03-31 22:46:04.612: E/AndroidRuntime(6806): at com.android.internal.policy.impl.PhoneWindow$DecorView.onWindowFocusChanged(PhoneWindow.java:2041)
03-31 22:46:04.612: E/AndroidRuntime(6806): at android.view.View.dispatchWindowFocusChanged(View.java:3788)
03-31 22:46:04.612: E/AndroidRuntime(6806): at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:658)
03-31 22:46:04.612: E/AndroidRuntime(6806): at android.view.ViewRoot.handleMessage(ViewRoot.java:1923)
03-31 22:46:04.612: E/AndroidRuntime(6806): at android.os.Handler.dispatchMessage(Handler.java:99)
03-31 22:46:04.612: E/AndroidRuntime(6806): at android.os.Looper.loop(Looper.java:123)
03-31 22:46:04.612: E/AndroidRuntime(6806): at android.app.ActivityThread.main(ActivityThread.java:4633)
03-31 22:46:04.612: E/AndroidRuntime(6806): at java.lang.reflect.Method.invokeNative(Native Method)
03-31 22:46:04.612: E/AndroidRuntime(6806): at java.lang.reflect.Method.invoke(Method.java:521)
03-31 22:46:04.612: E/AndroidRuntime(6806): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
03-31 22:46:04.612: E/AndroidRuntime(6806): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
03-31 22:46:04.612: E/AndroidRuntime(6806): at dalvik.system.NativeStart.main(Native Method)

Thanks in advance
najhi
 
Posts: 13
Joined: Sat Mar 31, 2012 9:36 am

Re: Advanced Menus

Postby OzLark » Sun Apr 01, 2012 1:50 am

By looking at that stack trace, you have a NullPointerException at: com.najhi.andengine.CustomMenuScene.add(CustomMenuScene.java:149)

We can't see that line here.
Did this post help you? Feel free to return the gesture by downloading Ninja Bees, creating a level (or more) and sharing it to the Ninja Bees website!

Ninja Bees - Our latest Android game, check it out on Google Play (free) or paid with no ads
OzLark
 
Posts: 1130
Joined: Sun Feb 05, 2012 3:19 am

Re: Advanced Menus

Postby najhi » Mon Apr 02, 2012 7:47 pm

hello

sir it is methodin's built class customMenuScene.java downloaded from the given link.
https://github.com/methodin/Andengine-P ... CustomMenu
najhi
 
Posts: 13
Joined: Sat Mar 31, 2012 9:36 am

Re: Advanced Menus

Postby OzLark » Tue Apr 03, 2012 12:33 am

Ok,

That method is:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public CustomMenuScene add(Shape pEntity) {
  2.                 final String name = pEntity.getClass().getSimpleName();
  3.                 if(name.equals("SpriteMenuItem")
  4.                         || name.equals("AnimatedSpriteMenuItem")
  5.                         || name.equals("Text")
  6.                         || name.equals("Sprite")
  7.                         || name.equals("AnimatedSprite")
  8.                 ) {
  9.                         this.getFirstChild().attachChild((IShape)pEntity);
  10.                         if(name.equals("SpriteMenuItem") || name.equals("AnimatedSpriteMenuItem")) {
  11.                                 this.mMenuItems.add((IMenuItem)pEntity);                       
  12.                                 this.registerTouchArea((IMenuItem)pEntity);
  13.                         }
  14.                 }
  15.                 currentContainer.add(pEntity);
  16.                 return this;
  17.         }
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


In the latest version, line 149 is: if(name.equals("SpriteMenuItem"), I can't see this being the issue, so I assume that your version is slightly different.

Can you find the line that is failing and post the relevant code.
Did this post help you? Feel free to return the gesture by downloading Ninja Bees, creating a level (or more) and sharing it to the Ninja Bees website!

Ninja Bees - Our latest Android game, check it out on Google Play (free) or paid with no ads
OzLark
 
Posts: 1130
Joined: Sun Feb 05, 2012 3:19 am

Re: Advanced Menus

Postby najhi » Wed Apr 04, 2012 8:02 pm

i am getting it on "this.getFirstChild().attachChild((IShape)pEntity);"
i think this.getFirstChild() is empty but i dont know how to fill it.

if i comment this line i could no find any exception but i also could not see any menu although it pauses the engine after pressing the menu button..
najhi
 
Posts: 13
Joined: Sat Mar 31, 2012 9:36 am

Re: Advanced Menus

Postby OzLark » Thu Apr 05, 2012 4:00 am

Edit - removed incorrect solution...
Did this post help you? Feel free to return the gesture by downloading Ninja Bees, creating a level (or more) and sharing it to the Ninja Bees website!

Ninja Bees - Our latest Android game, check it out on Google Play (free) or paid with no ads
OzLark
 
Posts: 1130
Joined: Sun Feb 05, 2012 3:19 am

Re: Advanced Menus

Postby najhi » Sat Apr 07, 2012 11:31 am

hello

i could not understand your last post. can you please provide me simple but complete working example of advance menu?
my email id is najhi_1989@hotmail.com. will be grateful to you.
thank you
najhi
 
Posts: 13
Joined: Sat Mar 31, 2012 9:36 am


Return to Features

Who is online

Users browsing this forum: No registered users and 5 guests