This WebView merged into cocos2d-x3.3!
Please use cocos2d/cocos2d-x
- cocos2d-x ver3.0(or greater
- android-10(or greater
- create libs directory under target project and clone this repository.
cd /path/to/my-project
mkdir libs && cd libs
git clone [email protected]:gin0606/cocos2dx-WebView.git
- Add
cocos2dx-WebView/common
andcocos2dx-WebView/ios
to your project.
- Update project.properties file.
cd /path/to/my-project/libs/cocos2dx-WebView/android/java
android update project -p . -t [android API level]
android update project -p . -l /path/to/my-project/cocos2d/cocos/platform/android/java
cd /path/to/my-project/proj.android
android update project -p . -l /path/to/my-project/libs/cocos2dx-WebView/android/java
- Update Android.mk file.
open /path/to/my-project/proj.android/jni/Android.mk
-# LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static
+LOCAL_WHOLE_STATIC_LIBRARIES += cocostudio_static
+LOCAL_WHOLE_STATIC_LIBRARIES += cocos_webview_plugin_static
-# $(call import-module,editor-support/cocostudio)
+$(call import-module,editor-support/cocostudio)
+$(call import-module,../../libs/cocos2dx-WebView/android)
- Edit Activity class to handle Cocos2dxWebViewHelper instance.
public class AppActivity extends Cocos2dxActivity {
private Cocos2dxWebViewHelper mWebViewHelper = null;
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(mWebViewHelper == null){
mWebViewHelper = new Cocos2dxWebViewHelper(mFrameLayout);
}
}
}
#include "WebView.h"
auto webView = cocos2d::plugin::WebView::create();
webView->setContentSize(cocos2d::Director::getInstance()->getVisibleSize());
webView->setPosition(cocos2d::Director::getInstance()->getVisibleSize() / 2);
webView->loadUrl("http://www.google.co.jp");
this->addChild(webView);
// if set js scheme. call `onJsCallback` when load `hoge-scheme://foo`.
webView->setJavascriptInterfaceScheme("hoge-scheme");