Making JavaFX operational to the mobile platform has always been a community effort.
Of course, now that JavaFX is ready to run to Android and iOS, let's take a look at how to package your own JavaFX project to the Android platform.
First download the following example: Http://pan.baidu.com/s/1bnwIYrP
This example is what I have modified from the example of packaging an official example to package a simple JavaFX program.
The example structure is as follows:
As you can see from the directory structure, the example is using theGradleto build.Gradleis also a foreign very fire automated building tools.
The first time you pack, you need to double-clickGradlew.bat, will download a series of libraries and packages, here may take a lot of time, everyone needs and so on.
You need it when you pack.NoteThe following steps:
1.The project code for JavaFX is placed under the src/main/java/folder
2.The resources required by JavaFX are placed under the Src/main/resources/folder
3.Modify the Build.gradle file, inside theMainclassnameRepresents the package structure of the JavaFX master class,ApplicationpackageRepresents the package name of the generated Android APK program, and of course we can also specify our own XML, which is something that needs to be researched later.
4.Add in Environment variablesAndroid_homethat specifies the directory for the ANDROIDSDK.
After completing the above operation, through CMD into the directory of the sample folder, runGradle RunTo see if they can run, and if they run, executeGradle AndroidTo pack our APK program.
The packaged apk is placed under the Build/javafxports/android directory.
In addition, there is an important point, according to the official note, the JavaFX program needs to set the stage size by the following code, otherwise there is a problem with the program resolution and display on the Android device.
Rectangle2D bounds = Screen.getprimary (). Getvisualbounds (); Scene scene = new Scene (root, Bounds.getwidth (), Bounds.getheight ());
The effect of running on Android is as follows:
Click on the color, and the text will be displayed synchronously, which works well.
I have previously written in JavaFX's example of SLG, can also be packaged to run on the phone, only individual problems, of course, because there is no resolution for mobile devices to adjust.
Interested friends can try their own, follow-up I will do related research, have problems can be directly commented, there is time I will reply to the answer.
--------------------------------------------------------------------------------------------------------------- -------------------------------
Recently Twitter and YouTube were more than a few days of research on the JavaFX package to Android. Basically no big problem, now support for various platforms to do different operations, you can add Android ads, call Android features and so on. But the efficiency of the JavaFX game packaged on Android is not optimistic, and I've written a few examples to pack on Android.
JavaFX game on Android efficiency feel general, I wrote a simple game engine to write some examples packaged to Android, the object is not a lot of cases are probably between 50-60fps. A simple image, added 100 to the same screen, FPS dropped to 20-30. Of course, PC and Android performance is very different, at least 3,000 image,fps on the PC will be about 30 (PC test). However, after all, it is not too embarrassing to use OpenGL to do the underlying drawing and to run the efficiency on Android.
Let's see what we can do next.
--------------------------------------------------------------------------------------------------------------- ------------------------------
This article is personal original, reproduced please indicate the source, I csdn blog: http://blog.csdn.net/wingfourever, personal blog address: http://www.wjfxgame.com.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
JavaFX packaged on Android