Results 1 to 8 of 8

Thread: Convincing the compiler

  1. #1

    Convincing the compiler

    Hey guys,

    I'm messing around with Oxygene for Java and the JMonkey Engine.
    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:
    Code:
    control = player.getControl(AnimControl.class);
    which I've rewritten as:
    Code:
    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?
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  2. #2
    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.

  3. #3
    Sorry, I should probably have added:

    Code:
    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.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  4. #4
    @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, lwjgl and jMonkey.

    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
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  5. #5
    JMonkeyTemplate.zip

    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.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

  6. #6
    Thanks so much mate!
    I guess I could add the jars as a reference and copy local

    cheers,
    Paul
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  7. #7
    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
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  8. #8
    nah, I would use slick for 2d. possibly combine it with Artemis. But I haven't tried it with oxygene myself.
    Imagine I've written something clever here inspiring you to make something awesome. If that happens give me credits

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •