Nez: free, open source 2D framework

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;
	}

Late reply, been out of town and off the grid for a few weeks. That could either just use boxcastBroadphase with layers or boxcastBroadphaseExcludingSelf. Same results either way.

1 Like

Hello @prime31 and community :slight_smile:
I somewhat confused about handling Tiled assets and was hoping you can spare a moment of your time for me.
In the YT video about using Tiled you import the assets using Content.mgcb but then I failed to locate required dll’s as well as Nez.PipelineImporter does not seem to be in master any more (?)
Please advise where can I find the required dlls.

From the Nez.Samples I can see that I can load assets directly with LoadTiledMap and set my files to ‘Copy if newer’.
As a newcomer to monogame I have absolutely no idea if there is a reason to go for pipeline importer or stick to loading files directly.

Any advice/info is much appreciated :slight_smile:

Thank you all o7

Nez stopped using the Pipeline tool entirely with version 0.10. You can now load Tiled maps directly. Just look at the Nez.Samples repo for examples.