我想要像示例
这样的东西这是我的按钮代码: 我想删除帮助按钮并在Google Play市场中为应用添加按钮
请帮助我:这是一个java文件
正如我所说,我想要一些能够列出我的3个游戏的内容,就像屏幕截图
一样我已经搜索了一些例子,但它不起作用
// buttons
CCMenuItemImage play = CCMenuItemImage.item("menu/play1.png", "menu/play2.png", this, "onPlay");
play.setAnchorPoint(1, 0);
play.setPosition(G.width, 0);
CCMenuItemToggle sound = CCMenuItemToggle.item(this, "onSound",
CCMenuItemImage.item("menu/sound_off.png", "menu/sound_off.png"),
CCMenuItemImage.item("menu/sound_on.png", "menu/sound_on.png"));
sound.setSelectedIndex(G.sound?1:0);
sound.setPosition(G.width*0.4f, 70);
CCMenuItemToggle music = CCMenuItemToggle.item(this, "onMusic",
CCMenuItemImage.item("menu/music_off.png", "menu/music_off.png"),
CCMenuItemImage.item("menu/music_on.png", "menu/music_on.png"));
music.setSelectedIndex(G.music?1:0);
music.setPosition(G.width*0.5f, 70);
CCMenuItemImage help = CCMenuItemImage.item("menu/help1.png", "menu/help2.png", this, "onHelp");
help.setPosition(G.width*0.6f, 70);
CCMenu menu = CCMenu.menu(play, sound, music, help);
menu.setPosition(0, 0);
addChild(menu);
setIsKeyEnabled(true);
}
public void onPlay(Object sender)
{
if( G.sound ) G.soundClick.start();
CCScene s = CCScene.node();
s.addChild(new SelectLayer(false));
CCDirector.sharedDirector().replaceScene(CCFadeTransition.transition(0.7f, s));
}
public void onSound(Object sender)
{
if( G.sound ) G.soundClick.start();
G.sound = !G.sound;
SharedPreferences sp = CCDirector.sharedDirector().getActivity().getSharedPreferences("GameInfo", 0);
SharedPreferences.Editor et = sp.edit();
et.putBoolean("sound", G.sound);
et.commit();
}
public void onMusic(Object sender)
{
if( G.sound ) G.soundClick.start();
G.music = !G.music;
SharedPreferences sp = CCDirector.sharedDirector().getActivity().getSharedPreferences("GameInfo", 0);
SharedPreferences.Editor et = sp.edit();
et.putBoolean("music", G.music);
et.commit();
if (G.music)
{
G.bgSound.start();
}
else
{
G.bgSound.pause();
}
}
public void onHelp(Object sender)
{
if( G.sound ) G.soundClick.start();
CCScene s = CCScene.node();
s.addChild(new HelpLayer());
CCDirector.sharedDirector().replaceScene(CCFadeTransition.transition(0.7f, s));
}
public boolean ccKeyDown(int keyCode, KeyEvent event)
{
int pid = android.os.Process.myPid();
android.os.Process.killProcess(pid);
Runtime r = Runtime.getRuntime();
r.gc();
System.gc();
return true;
}
}
答案 0 :(得分:0)
你可以试试这个,它对我有用
final ImageButton mybutton = (ImageButton) findViewById(R.id.imageButton);
mybutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String str ="https://play.google.com/store/apps/details?id=ws.crandell.newspaperpuzzles";
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(str)));
}
});