Nez: free, open source 2D framework

The core of Nez is fairly complete. I don’t think it will ever be 100% complete, but at this point it’s pretty solid and very flexible. For example: out of the box, the renderer can be used in standard forward rendering, deferred rendering, multi-render target blends and pretty much anything else you would want to do. This was all added with no changes to Nez code.

As for Components to build on the framework itself, there are always more that can be added. Anything that is not game-specific for example would be a good candidate. Most Components are usually game-specific though so they wouldn’t work as building blocks in the engine proper.

For anyone interested, Nez now has a dedicated Discord channel. It’d be awesome to get some participation there to discuss the framework in detail, cover different implementations and problem solutions, show off work, help each other work through problems and discover some of the more “hidden” features and maybe discuss how we as a community might able to help contribute to the project.

Hello, could someone help me fix this problem I posted here ?

Hello, can XMLTemplateMaker write the data to the xml file?

It does exactly the opposite: it reads the XML into a strongly typed object at runtime.

In other words, I can’t use it to save the runtime data. If so, how do I save the data to xml using nez.

The same way you would any C# program: use any of the various XML classes in the .NET framework or a third party XML lib.

Thanks for your reply.

Hello, I have a problem about Nez.UI. I create a entity as my player and I add the CameraFollow to the player.The problem is that when my player moved and the camera followed,but Nez.ui is not working.For example, button.onclick is not working.

I got it. I change the inputpos.The button is working.But I don’t know that if so, are there other bug about nez.ui.

Does NEZ have support a on screen virtual joystick and buttons? I want to create a game for android and I need to draw a buttons and joystick on screen.
I can not find this feature in NEZ.
I don’t want to make a job that already has done by others.

Virtual joysticks and buttons are very game specific features (and not very difficult to make). If you are looking for anything that game-specific Nez isn’t for you. It is a framework meant to be built upon, not just parts you glue together randomly to make a game.

2 Likes

Hey @prime31, fantastic framework from what I’ve seen so far and I’m thinking of moving my current project over!

Can I just ask what would you do if you needed one entity (or entity system) to have access to another entity?

I’m struggling to see how I would write a game where entities wouldn’t need direct access to other entities at some point yet with ECS I don’t see many examples.

Two examples I did see in the Nez Samples was calling a method on the scene to launch missiles or using an Entities access to it’s parent scene as a way to then get access to another entity. Is that the preferred way or should I be looking at design pasterns that avoid this completely?

Sounds like skipping the ECS is a good idea if you already have code you are moving over. Just use the standard EC, which is really how Nez works best. You can then find other Entities and Components via the Scene.

Cool! So you think Nez works best as per your samples of having components contain logic and not just data?

If a component wants to update the property of a component on another entity you would happily do something like this in a ShipComponent:

((GameScene).entity.Scene).PlayerEntity.getComponent().Score += 100;
or
entity.scene.findentity(“player”).getComponent().Score += 100;

I actually have a bunch of “manager” classes for things like generating planets, which I thought may lend itself quite well to Systems but will probably work fine as EC’s on the scene themselves.

I wouldn’t go that route. Just use findEntity at Scene start and cache your Entities

Thanks buddy. Just to be clear (and I’m not missing out on some other cool Nez feature) when you say “cache your Entities” you mean to set the Entity as a class property of the Scene via findEntity at the start and then access it via that instead of calling findEntity each time?

I believe that’s what I was getting at with my first example when I set it to PlayerEntity and just access it from the scene.

Just want to say thanks for your efforts with Nez.

When i say cache, i just mean do the lookup just once and store the result. You don’t want to be calling findEntity every frame. Store the reference in your Component subclass. No need to subclass Scene and store them there.

Quick question (apologize if asked before), I see that the Nez.Samples window size remains fixed after a change in resolution or when moving from one resolution monitor to a different resolution monitor, I’m trying to get the same functionality but my Nez project changes window size when moving the window from one resolution monitor to a different resolution monitor. Any ideas how to achieve this?

Hey @prime31, loving Nez! Really going to push it (and Monogame) when the project is finished. I think Nez should be officially added to the Monogame family as the optional layer that sits above MG when an EC(S) framework is needed.

Anyway, I’ve used ProjectileMover and noticed the move always returns true because “neighbours” contains the projectile’s collider and then checks overlaps() with itself. Strangely the NezSample NinjaGame works but I think that’s because you’re specifying a layer which I’m not (and I don’t see why specifying a layer would stop it returning itself)?

Wondering if boxcastBroadphase shouldn’t be boxcastBroadphaseExcludingSelf instead?

Here’s the current method for move() in ProjectileMover:

	/// <summary>
	/// moves the entity taking collisions into account
	/// </summary>
	/// <returns><c>true</c>, if move actor was newed, <c>false</c> otherwise.</returns>
	/// <param name="motion">Motion.</param>
	public bool move( Vector2 motion )
	{
		if( _collider == null )
			return false;

		var didCollide = false;

		// fetch anything that we might collide with at our new position
		entity.transform.position += motion;

		// fetch anything that we might collide with us at our new position
		var neighbors = Physics.boxcastBroadphase( _collider.bounds, _collider.collidesWithLayers );
		foreach( var neighbor in neighbors )
		{
			if( _collider.overlaps( neighbor ) )
			{
				didCollide = true;
				notifyTriggerListeners( _collider, neighbor );
			}
		}

		return didCollide;
	}