Permalink
Browse files

Merge pull request #101 from nazgee/for-nicolas-mMenuItems

Add clearMenuItems() method to MenuScene. Made mMenuItems protected.
  • Loading branch information...
2 parents 9c68e7a + 4db8c5c commit b631d500800cdff79411996f149dac87072f9833 @nicolasgramlich committed May 14, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/org/andengine/entity/scene/menu/MenuScene.java
@@ -1,6 +1,7 @@
package org.andengine.entity.scene.menu;
import java.util.ArrayList;
+import java.util.Iterator;
import org.andengine.engine.camera.Camera;
import org.andengine.entity.scene.CameraScene;
@@ -30,7 +31,7 @@
// Fields
// ===========================================================
- private final ArrayList<IMenuItem> mMenuItems = new ArrayList<IMenuItem>();
+ protected final ArrayList<IMenuItem> mMenuItems = new ArrayList<IMenuItem>();
private IOnMenuItemClickListener mOnMenuItemClickListener;
@@ -83,6 +84,14 @@ public void addMenuItem(final IMenuItem pMenuItem) {
this.registerTouchArea(pMenuItem);
}
+ public void clearMenuItems() {
+ for (int i = mMenuItems.size() - 1; i >= 0; i--) {
+ IMenuItem menuitem = mMenuItems.remove(i);
+ detachChild(menuitem);
+ unregisterTouchArea(menuitem);
+ }
+ }
+
@Override
public MenuScene getChildScene() {
return (MenuScene)super.getChildScene();

0 comments on commit b631d50

Please sign in to comment.