1

我在 cocos 2d-x 中打开链接(在以前的版本中),例如:

CCApplication::sharedApplication()->openUrl("http://www.google.com");

此链接的帮助:

https://github.com/cocos2d/cocos2d-x/pull/4893/files

但在新版本中 openUrl 不再存在。

那么我现在如何在新版本中打开链接?

4

1 回答 1

3

您具体针对哪个操作系统,您可以尝试为 iOS 编写 Obj-C 代码并将其放入

#ifdef (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)

    NSURL *url = [NSURL URLWithString:@""];  
    [[UIApplication sharedApplication] openURL:url];

    #万一

并在源文件上添加编译器标志 obj-c 和 c++

同样,在 android 上,您可以进行 JNI 调用(Java 代码)

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("<link>"));
startActivity(browserIntent);

关于如何从 cocos2d-x http://purplelilgirl.tumblr.com/post/54583532324/code-bit-how-to-use-jni-in-cocos2dx-android调用 jni

引用自 如何从我的应用程序在 Android 的 Web 浏览器中打开 URL?

于 2014-04-30T10:42:57.603 回答