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.).
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).
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.
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 ?
Hi there. Iām struggling a bit with the UI, first problem is that text rendering isnāt perfect, this simple code:
var canvas = createEntity("ui").addComponent(new UICanvas());
var skin = Skin.createDefaultSkin();
var table = canvas.stage.addElement(new Window("window", skin)).setMovable(true).setResizable(true);
table.pad(10).setPosition(10, 10);
var inpt = new TextField("input", skin);
table.add(inpt).pad(10).setRow();
var button = new TextButton("click", skin);
table.add(button).size(100,20).setRow();
table.pack();
produces this:
Everything works, but besides the ugly rendering, a resizable and movable window has an extremely small drag area on the titlebar to move, like 1px or so, a bit up and you resize it.
Also, when you just want to pass a simple image in an Nez.UI.IDrawable typed parameter, is SubtextureDrawable the appropriate object to use?
Is there a multi-line text input, or maybe a multi-line mode for the normal text input?
It seems to be a bug or incompatibility with FNA (17.05). Somewhere a value is off by one, Iāve printed the usual suspects from FNA but the values are consistent, at least with the window and framebuffer dimensions. Anyway, I managed to workaround that with a quick hack:
On ECS/Camera.cs, add the following lines before the inverse transform matrix calculation (around L330):
I want to make it so that an Entityās Sprite flashes white when it gets hit. I think I need to create a shader and use that, but I am not sure how to apply a shader to a Nez Sprite. Is there any tutorial or reference describing how to do this? Am I supposed to be using a PostProcessor somehow? Thanks in advanced!
Nez includes a SpriteBlinkEffect that you can use to fully color a Sprite. All Effects are applied via a Material and all RenderableComponents can have their Material set via the setMaterial method.
Cant say I have any idea what 3.7 is bringing. All you have to do is change the Reference to your 3.7 build and the compiler will let you know straight away.
Matrix.Rotation and Matrix.Scale got removed, so if Nez uses that, you should switch to Matrix.Decompose.
Other than that there are no breaking changes so far.