我是android的新手。我正在使用cocos2d添加菜单。我可以成功添加菜单。但无法确定选择了哪个菜单项。我在下面给出了我的代码。请帮助。
for(int i=0;i<len;i++){
asn = CCMenuItemImage.item("ans_btn.png", "ans_btn_glow.png", "ans_btn.png", this, "check");
asn.setTag(i+1);
CCMenuItem[]item={asn};
menu = CCMenu.menu(item);
menu.setPosition(CGPoint.ccp(170,val));
addChild(menu);
val+=60;
}
public void check(){
// CCMenuItem answ=(CCMenuItem)sender;
String allert= null;
//CCMenuItem answ = sender;
//int check = answ.getTag();
int i =asn.getTag();
String str = Integer.toString(i);
String str1 = Integer.toString(rans);
if(i== rans)
allert = "right";
else
allert= "wrong";
CCLabel pop = CCLabel.makeLabel(str1, "DroidSans", 18);
pop.setPosition(CGPoint.ccp(200, 50));
addChild(pop);
CCLabel pop1 = CCLabel.makeLabel(str, "DroidSans", 18);
pop1.setPosition(CGPoint.ccp(200, 100));
addChild(pop1);
}