Hello guys, this is my first week using jMonkey and I am finding some trouble understanding assets even after reading the tutorials.
I have an Visualizer.java class that has the main and extends simpleApplication that get specific motion events passed to it and a Animator.java class that is responsible of the actual animation of these events. It’s a smaller design from a bigger one so don’t be surprised if it’s a little different than the usual. All the animation function are inside Animator class (that also extends SimpleApplication).
The issue I am having is when I start Visualizer.java and have to execute some motion event from Animator I get an assetManager == null error.
[java]
private static AnimatorCinematics myApp;
…
public AnimatorVisualizer( String filePath) {
myApp = new AnimatorCinematics(filePath);
}
[/java]
now in Animator.java the constructor is:
[java]
public AnimatorCinematics( String filePath) {
traceFile = new File(filePath);
// used to do other stuff
// issue is that I need to initialize the assetManager here or something
// otherwise if I call it at any point I’m gonna get a null ptr
}
[/java]
There is an AssetManager inside your SimpleApplication (especially if you create a simple framework using the SDK). Pass that AssetManager to anywhere you need it.
Read the tutorials, you have to do stuff in simpleInit(), when the constructor is called the assetManager is not prepared yet.
I decided to just keep one class extending SimpleApplication and animate in the other w/o extending anything. After reading the API more thoroughly the getters and setters should allow me to do all the work.
Now another issue I was having is using this function:
[java] inputManager.addMapping("3dCamView", new KeyTrigger(keyInput.KEY_3));[/java]
in a class that is an instance of the main (that extends simpleApplication but itself does not extend simpleApplication), I tried this:
[java]myApp.getInputManager().addMapping("3dCamView", new KeyTrigger(keyInput.KEY_3));[/java]
The issue is how to get the keyTrigger to work w/o having to extend SimpleApplication?
@normen said:
Read the tutorials
u were right I got it to work … thanks