Nez: free, open source 2D framework

Out of the box Nez provides the Emitter class for messaging. The Core class has its own Emitter as an example. The Input class also uses it for controller plug/unplug notifications.

If you are just looking for a generic messaging system grab MessageKit from my GitHub. It’s a very simple, generic, static messenger.

And finally, Nez lets you register a global manager on the Core class. If all else fails you can always add whatever you need there.

Transforms have no concept of pivots. They have no size so a pivot doesn’t really make sense. Sprites have an origin property that you can use for that.

Any reason why you chose to make your own UI instead of using something like EmptyKeys? Would EmptyKeys be easy to use alongside Nez?

Yup. Empty Keys is a bit heavy IMO for game UI. I wanted Nez to have a flexible UI that can easily be made via code without resorting to WPF/XAML. I personally am not a big fan of WPF/XAML after having used it for some business apps in the past.

That being said, there is no reason at all that you can’t use any UI system that you like with Nez. When it comes down to it every system will just be using a SpriteBatch or vertex buffers directly which is all Nez does for all of its renderables.

Where did you get your ideas for the ECS? Did you follow some other framework you have used before and liked or did you come up with some of the concepts yourself?

The EC portion was just what I always wanted having used a bunch of other entity frameworks. The S portion (entity systems) was based on Artemis which is really well done.

I’m having some trouble getting started with Nez because it doesnt seem to have a lot of examples or documentation. Anyway you would recommend to get a head start w/ Nez?

There are at least 10 pages of docs in the GitHub repo. The README links to each them. There is also a wiki with a few bits of info, an entirely separate repo of examples (Nez.Samples linked from the README) and a YouTube video walking through every step of the setup process.

Sorry, I didnt mean how to just get it started. I meant more in depth explanation of the different features. Looking through the source I see a ton of things but it’s not very clear how it all works together, patterns to follow, etc… I am wondering, are there any games you know being made w/ Nez that I could maybe look at? I know it takes time to create really extensive docs.

I am aware of a few folks using Nez for their games but I can’t imagine they would be willing to give out the source. I intend to open source one of the projects I am working on but it won’t be for some time.

Most of the larger core classes/ideas/layers are documented but there are definitely lots of smaller bits that aren’t yet documented. A pretty large amount of the code does have XML comments which are definitely worth giving a read as you come across them. Often the “how to” or “why” of a class will have a little explanation in the XML doc summary.

At this point, probably the best course of action would be to first check out the samples repo so you know what is in there. Once you have a grasp on that if you try making a little demo game (like long or something simple) you can explore a bit by just seeing what autocomplete comes up with for methods and even dig in and read some of the code comments (there are a TON in there!).

Feel free to ask any specific questions directly.

Do you have any plans for some sort of system to persist entities? I could get everything up and running quickly in Nez, except for this.

I’ve tried to use JsonSerializer to just quick and dirty serialize an entity, but as expected there doesn’t get very pretty when serializing textures and stuff haha.

Right now I’m manually writing the data I need to a JSON file, but there isn’t really a proper place inside Nez to do that now. Though there are a lot of things I hate about Unity, you get spoiled from their automagic serialization :p.

There aren’t any immediate plans for a full-on serialization system. Even if there are serialization utilities added they would never be like Unity. Unity has an editor that maintains a huge database behind the scenes with all the assets, relationships saved, changes synced, etc. Nez will never take on that much control and force anything overarching on devs using it so it won’t ever be able to maintain that kind of information on everything from assets to scenes to Component properties.

Similarly, the Nez runtime will never have that kind of thing going on either. It’s made to be more simple and lightweight than that. What it could gain is a more simple system much like the Entity.clone method. It would basically funnel down calls to a serialize and deserialize to Colliders and Components. To make something like that fully automatic just isn’t possible. Extra metadata would need to be kept on things like animations, subtextures from GDX atlases, Nez atlases, TexturePacker atlases, etc, etc.

You can see how that could spiral out of control fast. And that doesn’t even touch on things like forcing Components to have constructors with zero parameters and custom classes. Having serialize/deserialize methods coupled with empty constructors would help but it wouldn’t be perfect.

What kind of system would work for your particular needs is hard to say. It would depend on if you are making an in-game level editor, simple game state save, detailed game state save, etc.

Yeah that’s kind of what I imagined, I really hated not having constructors in unity as well haha.
The serialize/deserialize methods seem fine for the components, that’s what I imagined as well.
I just want to avoid this situation when deserializing the entity data;

string componentType = jsonReader.value<string>("type");

	case "sprite":
	//create sprite component and populate with supplied data
	case "rigidbody"

Anyways, thanks for the answer, I didn’t want to roll my own system yet before I knew if Nez would get it’s own implimentation.

Hi. This project seems awesome, but I’m having a number of rendering problems on some hardware, specifically black screen on intel integrated graphics and corrupted sprites on some discrete nvidia. What kind of black magic are you doing to the renderer? :smiley: I’m mostly interested in Nez.UI and tried to ‘detach’ it from the whole project without success. The other stuff also is very interesting though, so I don’t know if I’m doing something wrong or something, I’ve tried the samples both with the latest release and the trunk and both have the same problem (besides the lack of “Ragdoll” in the release, but that’s unrelated). I’m failing miserably to find a decent and ‘minimal’ UI for MonoGame and perhaps you could help me a bit to use Nez.UI, you know, maybe show me how to setup a very minimal Nez.Core subclass and somehow prevent Nez from changing the rendering stuff at all… I’m not using the other stuff, I’m drawing sprites directly to the screen and I just want to ‘overlay’ a simple UI. It’s really frustrating that something that simple is so hard to get running, I was going to make my own UI but gave up when I encountered hard problems like word wrapping and touch support. I refuse to believe there’s no way to achieve a decent UI in MonoGame easily. That’s like the most basic thing after being able to draw images on screen imho. Thank you in advance.

There is nothing at all remotely special about how Nez renders stuff. It works the same as any other MonoGame renderer would.

You should be able to pull the repo or the Samples repo and just run it. I have used it on both Mac and Windows computers with Intel integrated graphics with no issues whatsoever.

If you want to gut any parts of Bez and use them outside of it you’ll just have to pull out the code and fix errors as they come up. Nez parts are all designed to work together.

Thank you for your reply. Well, maybe something’s not quite right with my references. I’ve tried the samples and Nez once more, and just noticed something strange… Nez ships with a MonoGame, but I also have references to a MonoGame downloaded from NuGet and yet references to MonoGame in my system. Maybe that’s the problem. What’s that MonoGame DLL that ships with Nez? Is it a “MonoGameMini” or something? Anyway, I’m going to try it once more. Thanks.

Nez is a PCL and thus requires a PCL version of MonoGame to compile against. It is an empty PCL and not actually used except for compilation.

You’re better off using the latest nightly build of MonoGame rather than the latest stable release. I’ve had plenty of problems with the 3.5.x serie and not just with Nez.


Hello. I’m new to game developing(programming) and Nez seems to be good! I read Core and some other classes, and found I can glasp them.

Excuse me for my elementary question. Does Nez have sprite operation system such as Cocos2d’s Action?

If I tell a sprite to move at some point in x frames after y frames, it will go there smoothly and automatically. That’s what I want.

Then, should I create my own action system (maybe using Nez’s tweening system) or Nez has one?

Thank you.

Nez has a tweening system built in along with extension methods to make using it simple. Just type “.tween” after anything to see your options. For example, when you type “entity.transform.tween” you will have options to tween position, scale, rotation, etc. Any field or property can be tweened.

Oh, they run automatically. It’s cool and flexible. Thank you!!
And I found TweenManager’s stopAllTweensWithTarget(), which is more than I expected. Really cool, thank you again!