View Full Version : Convincing the compiler
02-04-2012, 11:05 PM
I'm messing around with Oxygene for Java and the JMonkey Engine (jmonkeyengine.com).
I'm trying to rewrite the Java beginner tutorials in Oxygene and now I've encountered a problem I don't know how to tackle.
In Java the code is:
control = player.getControl(AnimControl.class);
which I've rewritten as:
control := AnimControl(player.Control[typeOf(AnimControl)]);
However the compiler complains that: 'Generic parameter doesn't validate on "com.jme3.scene.control.Control" constraint for "T"'
But "AnimControl" inherits from "com.jme3.scene.control.AbstractControl" which implements the "com.jme3.scene.control.Control" interface.
Does anyone have an idea on how I can convince the compiler that "AnimControl" is a valid class?
04-04-2012, 08:46 PM
I'm not sure what you are trying to do with that code, but I don't think a typecast is the right course of action.
05-04-2012, 04:08 AM
Sorry, I should probably have added:
var control: AnimControl;
hence the typecast since player.Control returns a Control (an interface AnimControl implements). I still get the error without the typecast so it has nothing to do with it.
For now I've managed to work around the issue since there's an overloaded version of player.Control where I can pass an integer. I simply traverse through all the controllers in player and check if the current controller is of the type I want.
13-04-2012, 01:55 PM
@pstudio: I know this is off-topic, but I have had no luck so far getting an external java library to both compile + run successfully without compiler errors or just runtime crashes...
I have tried slick (http://slick.cokeandcode.com), lwjgl (http://www.lwjgl.org) and jMonkey (http://jmonkeyengine.com/).
I don't suppose you could share a working bare bones minimum jmonkey project that compiles and works under Oxygene so I can see what I might be missing?
I have wasted a day on this and I am rapidly running out of time with the competition if I want to use Oxygene :(
13-04-2012, 11:38 PM
This is a simple project but without the needed jar files (I haven't bothered sorting out the stuff I don't need so the jars are 65 mb right now)
You will need to download the jars from http://jmonkeyengine.com/nightly/ (I've used jME3_2012-03-30) and resolve the references yourself.
The jars provided with the JMonkey SDK did not work for me. Add them as reference and make sure they're set to be copied to the output folder. This was the only way I could make the compiled jar work.
Note that I haven't been able to debug from Visual. The program will start and show you a menu for selecting resolution but when you press play VS will crash. However the compiled jar works fine.
14-04-2012, 12:10 AM
Thanks so much mate!
I guess I could add the jars as a reference and copy local :)
14-04-2012, 06:43 AM
Well I got my version working ok after using your template and the nightly build...thanks again!
On the other hand, I just want to do a 2d game made mainly of tiles with a small amount of special moving objects....not sure if I can do this easily with JMonkey though :)
14-04-2012, 02:07 PM
nah, I would use slick for 2d. possibly combine it with Artemis (http://www.gamadu.com/artemis). But I haven't tried it with oxygene myself.
Powered by vBulletin® Version 4.1.10 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.