Is it possible to make a 2D game with jme3 yet?

Hello everyone,

I was just wondering if it’s possible to make a 2D game with JME3 yet? I’ve looked around this forum for the answers to this question and their dating waaay back to 2012 (or earlier) and say to attach everything to the guiNode. My issue with that is that they also say it’s bad practice to do that as that node is responsible for the GUI only.

I’ve tried the likes of LibGDX but found it too clunky or confusing to use. Whereas I prefer JME3 as the was it’s set out is extremely beautiful and easy to use.

If it is possible how could I do it?

Mainly what I need to do is just get an animated sprite to walk around with two images on a tile map. One way I could probably do it is to use a particle, but that just seems wrong to me. Anyone else have any ideas?



Sure you can.
Here is what I did this week.

And have a look here:

1 Like

OK cool, how could I do something like that then? :L

Have a look at my library.

I’ll give that a crack and let you know how I get on! Thank you!!!

I made an Android game some months ago and released it on play store. Here’s link if you want to give it a try and see how JME is working for 2d games: [ARCADE] [ANDROID] Karma Siege

If you don’t want to attach everything to guiNode you can maybe write a class that acts like a proxy from 2d to 3d,transforming your 2d coordinates into a Vector3f that’s suitable to be used as a local translation,and attach everything to rootNode. However,this is a bit tricky and you have to transform coordinates really precisely or you can have some issues with things like click events.

I’ve always just made my own controls for the spatials which only lets them move in 2 dimensions. You WILL hit draw order problems which you will need to sort out if you are using textured sprites, as the 3d engine will draw through each other and you will get z-fighting. You should be able to fix this by offsetting the objects on the camera axis. It’s also important to note that it will be difficult to get pixel-perfect sprites to appear on screen correctly as by default jmonkey uses floats and 3d objects. None of this is impossible to overcome, just things to be aware of.

Except the issue I’m having at the moment is this:

I want to make say a sprite man. - This is the simple bit I know.
When the player presses any direction, the sprite changes:
left and right - when left the sprite image flips and changes between a static sprite and a “walking” sprite, ditto with right but the sprite can be flipped to original facing.

up and down - again this is kinda simple, when up the sprite is showing the “back” of the man sprite which has a static image and a single walking image. ditto for going down, which is simple as it just involves changing the sprite to the front sprite.

This is accomplished by changing the index that the sprite shader should use on a texture atlas containing each image of the animation.

That link should get you started

1 Like

Because 2D is not really a jME thing for most I will share a little bit.

If you look at the ninja character in this video, I am making use of my framework Galago to make a animated sprite node.

Here is the spritesheet:

And simple code for animated sprite functionality.

//Initialize the sprite
        sprite = new AnimatedSprite("mysprite", 1f, 1f, 4, 4, 0);
        sprite.addAnimation(new Animation("idle", 0, 3, 10));
        sprite.addAnimation(new Animation("run", 4, 7, 10));
        sprite.addAnimation(new Animation("jump", 8, 11, 10));
        sprite.addAnimation(new Animation("kick", 12, 13, 10));


        //Play the animation like this"idle", true, false, true);
1 Like

While @ndebruyn approach gets the job done quickly, I think that MonkeySheet is more powerful:

  • animations are defined on JSON and you can recycle frames to make long animations
  • sprite baching support
  • supports some basic material color effects