These days our new game on the line, to tell the truth is quite fun. The first is the Mac version, the release of the Android version of the two days, the Android version of the profitability of the main consideration is advertising. Here is a record of some of our experience in integrating advertising.
The bottom of our game engine is packaged based on Gomobile, but Gomobile does not provide any way to integrate with third-party jar packages, although Java code can be called in Go->cgo-java Way, but new Java code cannot be added. The solution is very simple, create a new Android project directly, then bake the packaged .so files to the jniLibs catalog, then you can run the Android project directly.
The following are the specific implementation details:
- Create a new Android project
- Copy the Gonativeactivity.java from Gomobile to the new project
- Copy files packaged with Gomobile
.so to the JNI directory
- Configure
AndroidManifest.xml Activity to use replication
Compile and run, you can now find that Android projects are already happily running our Go project. .soand how did it come from? You can use it gobind or gomobile build .apk extract it directly from the package file.
The next step is to add ads, add ads to the process and add ads to normal Android projects without any difference. When we add ads to Gonativeactivity.java, it's important to note that the activity is inherited from a NativeActivity hierarchy with no view, and the general solution is to use a popupwindow to load the view of the ad.
In fact, it is very simple, in our implementation is probably such a few lines of code:
// 装在广告Viewpopup = new PopupWindow(this);popup.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));// bannerAdView adView = new AdView(this);popup.setContentView(adView);// 在屏幕下方显示广告popup.showAtLocation(getWindow().getDecorView(), Gravity.BOTTOM, 0, 0);
After you integrate your ads, you can pack your signatures like normal Android projects, not here.
In fact, this practice also gives us a way to do Android packaging, you can divide the project into Android and Golang parts, the use of a unified script package, so whether the Java or Go code changes can be used in the same packaging script to execute, The operation may be much simpler.
In addition, a few of our new games--**shoot Stack * * (very beautiful):
Shoot Stack
The resolution is a little lower, in fact the HD version is very good. Due to the domestic special reasons for the domestic market is not available, now on-line itch.io you can download to MAC version: shooting! Block by ntop or download Android version in GooglePlay: Android:shoot Stackplay.google.com
Googleplay.jpeg
Tubing Video: Https://youtu.be/MGd_QJ_nahU