Nez: free, open source 2D framework

Any program that can export a BM font XML file should work fine. I personally use Glyph Designer and the website Littera. If I recall, the default Nez font was a Littera export.

I’m trying to use Nez with MonoGame develop branch. There’s a few easy tweaks needed to the Nez source, but I’m stuck building an updated MonoGame.Framework PCL.

I’ve built the PCL according to these instructions and referenced it from the Nez project, but Game.Window property seems missing?

How did you build the PCL that’s bundled with Nez?

The PCL included with Nez is ancient. It isn’t from the 3.6 branch at all. If I am not mistaken the MG crew actually has a development NuGet for a proper PCL now. I can’t tell you where you can find it though as I generally use FNA for everything so I haven’t updated to 3.6 myself yet.

The portable NuGet doesn’t install unfortunately, which is why I was trying to build my own:

Could not install package 'MonoGame.Framework.Portable'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile111', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Eh, it was easy in the end:

Following up on [SOLVED] MonoGame.Portable & Nez

I fired up my Windows 10 VM and put the Nez default effect sources into the 3.6 pipeline tool, but it produced .xnb files not the .mgfxo files (whatever those are?) Nez seems to want. I was able to build a test .mgfxo from the command line with 2MGFX and successfully run it on my Nez+MG3.6 iOS project so that part works, but I couldn’t see how to do it in a 3.6 content project.

I haven’t a clue. I didn’t update to 3.6 at all yet. I’m waiting for it to be released before updating. I had too many issues using it in beta state.

Hi. Is it possible to get the code for the sample UI project you used in this video

Also, does Nez UI already support animations? Not looking for anything fancy. A simple bounce in/out of elements will do it for me.

Thanks in advance.

That old test project was not of good enough quality to be released. It was very sloppy code thrown together for testing various UI bits.

There is no animation system built into the UI but Nez has a tweening system built in that can tween any basic math type so you can use it to tween just about anything.

Thanks. One more question, is it advisable to have two tables under one stage in a UICanvas? I’m having trouble centering interactable elements(buttons, menus) when they are in the same table as my information ui elements(life bars, score, etc.).

You can certainly nest multiple UITables. In fact, some of the controls are just UITables under the hood.

Hello all, I have a function that moves my character a specified number of pixels that looks like this:

            if ( Input.isKeyPressed( Keys.W ) )
                battleMovement.mover.move( new Vector2( 0, -120 ), out battleMovement.res );
            else if ( Input.isKeyPressed( Keys.S ) )
                battleMovement.mover.move( new Vector2( 0, 120 ), out battleMovement.res );
            else if ( Input.isKeyPressed( Keys.A ) )
                battleMovement.mover.move( new Vector2( -128, 0 ), out battleMovement.res );
            else if ( Input.isKeyPressed( Keys.D ) )
                battleMovement.mover.move( new Vector2( 128, 0 ), out battleMovement.res );

This works obviously but what I’m hoping to do is to move the entity the specified distance and see the movement happen other than just the entity “popping” into position. Is there a good way to do this using Nez or is there someone who could clue me in on the best way that I could achieve this? Thanks!

If you want to see the motion you need to break it up into smaller steps and do the movement a little bit each frame. You can do it manually or via a fire and forget tween (see the tween* extension methods on Transform).

Are you suggesting that instead of a mover I use transform with one of the tweening methods?

It depends on if you want collision detection or not. If you do, break up your movement into smaller chunks and use the Mover.

Thank you for the informative response! : )

I would like to use a Xbox One Controller to handle input. What is the proper way to do this in nez? This pilfered code from the YouTube Tiled demonstration moves the ProtoTypeSprite happily.

if (Input.isKeyDown(Keys.Left)) _velocity.X = -moveSpeed;

So I authored this beauty after reading GamePadData.cs

if (GamePadData.isButtonPressed(Buttons.DPadLeft)) _velocity.X = -moveSpeed;

I am not an experienced programmer by any means but the logic seemed comparable. The impudent IDE demanded an object reference for non-static field, method or property.

After much research and failed solutions I returned, bestowing this:

GamePadData myGamePadData; 

and this:

if (myGamePadData.isButtonPressed(Buttons.DPadLeft)) _velocity.X = -moveSpeed;

That got rid of the squigglies but produced an unhandled exception, “object reference not set to an instance of an object” I know that these are simple coding errors due to my lack of understanding of C# and OOP. I feel like it’s the simplest, most basic oversight but I don’t see it. I know I’m misusing the GamePadData class and would like to see a proper implementation to learn from my mistakes if I may. I don’t ask for help carelessly, and appreciate any that’s offered.

There’s an example right in the Platformer Sample. It’s just what I was after. Great framework, very neat and concise. Almost entirely dummy proof too. :blush:

1 Like

Hi. I am trying to run Nez with DirectX. It seems to work but I got a problem on my Effect. For instance, I try to use the SepiaEffect on a single image sprite. I builded the SepiaEffect.fx with 2MGFX with the DirectX_11 Profile.

Following what I see in the samples doesn’t seem to make it. My guess was :

            var hero = myScene.createEntity("hero");
            hero.transform.position = new Vector2(200, 200);
            hero.addComponent(new Sprite(myScene.content.Load<Texture2D>("Characters/001-Fighter01")));
            hero.getComponent<Sprite>().material = Material.defaultMaterial;
            hero.getComponent<Sprite>().material.effect = content.loadNezEffect<SepiaEffect>();

But my sprite is not rendered at all. If I add a background sprite under my sprite hero, I get a sepia color all over the screen.

Do you happen to have a simple effect example on a single renderable ?

Nez only supports OpenGL. Nothing at all was ever tested for DirectX so you are on your own if you want to go that route.