我有一个CCMenu5 CCMenuItem秒.当用户触摸菜单项时,我希望菜单项移动到右边10个像素,以区别于其他像素.我尝试将每个菜单项设为全局变量,所以我可以说:if (item.isSelected) { [item runAction:blah]; }但这没有做任何事情.到目前为止这是我的代码:
CCLabelTTF *sin = [CCLabelTTF labelWithString:@"Single Player" dimensions:labelSize alignment:UITextAlignmentLeft fontName:font fontSize:20];
item1 = [CCMenuItemLabel itemWithLabel:sin target:self selector:@selector(goToSinglePlayer:)];
CCLabelTTF *spl = [CCLabelTTF labelWithString:@"Splitscreen" dimensions:labelSize alignment:UITextAlignmentLeft fontName:font fontSize:20];
item2 = [CCMenuItemLabel itemWithLabel:spl target:self selector:@selector(goToSplitscreen:)];
CCLabelTTF *ach = [CCLabelTTF labelWithString:@"Achievements" dimensions:labelSize alignment:UITextAlignmentLeft fontName:font fontSize:20];
item3 = [CCMenuItemLabel itemWithLabel:ach target:self selector:@selector(goToAchievements:)];
CCLabelTTF *str = [CCLabelTTF labelWithString:@"Store" dimensions:labelSize alignment:UITextAlignmentLeft fontName:font fontSize:20];
item4 = [CCMenuItemLabel itemWithLabel:str target:self selector:@selector(goToStore:)];
CCLabelTTF *set = [CCLabelTTF labelWithString:@"Settings" dimensions:labelSize alignment:UITextAlignmentLeft …Run Code Online (Sandbox Code Playgroud) 我正在尝试在Android链接中创建一个选项菜单 http://developer.android.com/guide/topics/ui/menus.html#options-menu
但我开发的菜单不是显示在我的页面底部,而是显示在顶部操作栏中.
我的xml是下面的my_options_menu.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/new_game"
android:icon="@drawable/menu_addnew"
android:title="???"
android:showAsAction="ifRoom"/>
<item android:id="@+id/help"
android:icon="@drawable/menu_addnew"
android:title="???????" />
</menu>
Run Code Online (Sandbox Code Playgroud)
我的java代码是
@Override
public boolean onCreateOptionsMenu(Menu menu){
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.my_options_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.new_game:
//newGame();
return true;
case R.id.help:
//showHelp();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
Run Code Online (Sandbox Code Playgroud)
我该怎么做才能在我的应用程序底部显示菜单而不是在顶部操作栏上?
我的菜单显示在下面的图像中

我想创建如下图像的菜单

怎么办?有人能帮我吗?
在我的 cocos2d 游戏中,我有一个“设置”按钮,它启动一个模态层,旨在锁定其下的所有内容。为此,我使用了锁定所有 CCMenuItem 的菜单状态方法的组合,并使用了覆盖层;两者都在代码下面。
问题是这两种解决方案似乎都不适用于 CCScrollLayers。当我单击按钮(启动模态)时,CCScrollLayer 仍然可以滚动,这不是我想要的。
我想:
我试过了:
CCTargetedTouchDelegate[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
self.isTouchEnabled = NO 在启动模态的层上
MenuStatus方法以使其适用于 CCScrollLayers,但它似乎不起作用。我不确定我做错了什么。我的代码现在如下。
// My main layer which launches the Settings Modal Layer
#pragma mark - Lock/Unlock layers
-(void) doSettings
{
[self lockLayers];
SettingsModalLayer *sml = [[[SettingsModalLayer alloc] init] autorelease];
[sml showSettingsOnLayer:self closeBlock:^{[self unlockLayers];}];
}
-(void) lockLayers
{
[[CCTouchDispatcher sharedDispatcher] addTargetedDelegate:self priority:0 swallowsTouches:YES];
[self MenuStatus:NO Node:self];
}
-(void) unlockLayers
{
[self …Run Code Online (Sandbox Code Playgroud)