How to add Acorus to an existing project
This is the start page of a web tutorial about the Acorus library.
If you’re creating a JMonkeyEngine desktop application from scratch, the BasicGame-on-Gradle project provides a good starting point. |
Adding Acorus to an existing JMonkeyEngine project is a 3-step process:
-
Add libraries to the classpath.
-
Convert the application to an
ActionApplication
orAcorusDemo
. -
Test and tune as necessary.
Add libraries to the classpath
Acorus comes pre-built as a JVM library that depends on:
-
jme3-core,
-
jme3-desktop, and
For projects built using Gradle or Maven, it’s usually sufficient to specify the dependency on the Acorus Library. Build tools should automatically resolve the remaining dependencies.
Gradle-built projects
Add to the project’s "build.gradle" or "build.gradle.kts" file:
repositories {
mavenCentral()
}
dependencies {
implementation("com.github.stephengold:Acorus:2.0.0")
}
For some older versions of Gradle,
it’s necessary to replace implementation
with compile
.
Maven-built projects
Add to the project’s "pom.xml" file:
<repositories>
<repository>
<id>mvnrepository</id>
<url>https://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.stephengold</groupId>
<artifactId>Acorus</artifactId>
<version>2.0.0</version>
</dependency>
Ant-built projects
Ant doesn’t know about transitive dependencies, so you’ll need to resolve them manually.
Download the Acorus library and its dependencies from GitHub and/or Maven Central:
You’ll definitely want the class JARs and probably the "-sources" and "-javadoc" JARs as well.
Open the project’s properties in the IDE (JME SDK or NetBeans):
-
Right-click on the project (not its assets) in the "Projects" window.
-
Select Properties to open the "Project Properties" dialog.
-
Under "Categories:", click on Libraries.
-
Click on the Compile tab.
-
Add the Acorus class JAR:
-
Click on the Add JAR/Folder button.
-
Navigate to the download directory.
-
Select the "Acorus-2.0.0.jar" file.
-
Click on the Open button.
-
-
(optional) Add JARs for javadoc and sources:
-
Click on the Edit button.
-
Click on the Browse… button to the right of "Javadoc:"
-
Select the "Acorus-2.0.0-javadoc.jar" file.
-
Click on the Open button.
-
Click on the Browse… button to the right of "Sources:"
-
Select the "Acorus-2.0.0-sources.jar" file.
-
Click on the Open button button again.
-
Click on the OK button to close the "Edit Jar Reference" dialog.
-
-
Add the other JVM libraries in a similar manner.
-
Click on the OK button to exit the "Project Properties" dialog.
Convert to an ActionApplication
JMonkeyEngine applications typically extend the SimpleApplication
class.
To use Acorus, an application should instead
extend ActionApplication
or one of its subclasses, typically AcorusDemo
.
-
ActionApplication
andAcorusDemo
are both abstract classes. -
ActionApplication
is simpler and easier to understand. -
AcorusDemo
extendsActionApplication
with features intended for demo apps.
ActionApplication
directly extends SimpleApplication
and has a similar interface (API).
The key difference is that startup code goes in a acorusInit()
method
instead of simpleInitApp()
.
|