在libgdx游戏中添加“评价我的应用”按钮
我想在我的游戏中添加一个按钮,该按钮将在Play商店中打开我的应用的网址。下面是我到目前为止,但是当我点击率按钮,它不会打开相应的网址。在libgdx游戏中添加“评价我的应用”按钮
我率的代码是:
if(Gdx.input.justTouched()){
guiCam.unproject(touchPoint.set(Gdx.input.getX(),Gdx.input.getY(), 0));
if(OverlapTester.pointInRectangle(rateButtonBound, touchPoint.x, touchPoint.y)){
try {
Process p = Runtime.getRuntime().exec("cmd /c start https://play.google.com/store/apps/details?id=com.shagunstudios.racinggame");
}
catch (IOException e1) {
System.out.println(e1);
}
if(Settings.soundEnabled)
Assets.click_sound.play(1.0f);
return;
}
}
你真正应该使用网络模块openURI方法。
喜欢的东西:
Gdx.net.openURI("https://play.google.com/store/apps/details?id=com.shagunstudios.racinggame");
exec
可能不是跨平台,并在至少在Android上是行不通的。
不要重新发明车轮。
将含有这样的代码的方法:
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("https://play.google.com/whateveryoururlis"));
this.startActivity(i);
在Android后端(在扩展的Libgdx AndroidApplication
的类)。然后使用接口将该方法暴露给独立于平台的Libgdx代码(并在您的其他后端提供占位符实现)。详情请参阅https://code.google.com/p/libgdx/wiki/ApplicationPlatformSpecific。
或者,你可以调用[openURI](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/Net.html#openURI(java.lang.String中)) 实际上确实Android中后端实现相同的事如果你看[源代码](https://github.com/libgdx/libgdx/blob/master/backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidNet.java)。 –
不适用于机器人或台式机 –
想要提供更多详细信息? –
嗯,现在是工作,我不知道为什么我用得到崩溃 –