XerShade Posted June 28, 2018 Share Posted June 28, 2018 So I'm working on a system in my game/engine to generate positions of the frames for actor sprites, the issue is when I run the code I get these "South, South, West, West, Right, Right, Up, Up, All" when I should be getting "South, West, East, North, Down, Left, Right, Up, All". Been looking for about 20 minutes now and can not figure out why the code is doing this.  The code generating the file: /// <summary> /// Generates a default texture matrix container. /// </summary> /// <param name="resource">The texture resource object.</param> /// <returns>The generated texture matrix container.</returns> public static TextureMatrixContainer Actor(TextureResource resource) { // Generate the container. var container = new TextureMatrixContainer(resource); // Calculate the frame dimensions. var frame = new Vector2f(resource.Size.X / 3, resource.Size.Y / 4); // Loop through the directions. foreach (Direction direction in Enum.GetValues(typeof(Direction))) { // Add the matriceis to the collection. container.Add(new TextureMatrix($"{direction.ToString()}-Idle", frame.X, frame.Y * direction.AsByte(), frame.X, frame.Y)); } // Return the container. return container; } The direction enumeration: https://github.com/XerShade/Astrendaria/blob/0.0.1/source/Astrendaria.Game/Enumerations/Direction.cs And the file it generates:  { "$type": "Astrendaria.Media.Matriceis.TextureMatrixContainer, Astrendaria.Media", "Components": { "$type": "Astrendaria.Classes.ComponentType[], Astrendaria", "$values": [ { "$type": "Astrendaria.Media.Matriceis.TextureMatrix, Astrendaria.Media", "X": 52.0, "Y": 0.0, "Width": 52.0, "Height": 72.0, "Bounds": { "$type": "SFML.Graphics.FloatRect, sfmlnet-graphics-2", "Left": 52.0, "Top": 0.0, "Width": 52.0, "Height": 72.0 }, "Name": "South-Idle" }, { "$type": "Astrendaria.Media.Matriceis.TextureMatrix, Astrendaria.Media", "X": 52.0, "Y": 0.0, "Width": 52.0, "Height": 72.0, "Bounds": { "$type": "SFML.Graphics.FloatRect, sfmlnet-graphics-2", "Left": 52.0, "Top": 0.0, "Width": 52.0, "Height": 72.0 }, "Name": "South-Idle" }, { "$type": "Astrendaria.Media.Matriceis.TextureMatrix, Astrendaria.Media", "X": 52.0, "Y": 72.0, "Width": 52.0, "Height": 72.0, "Bounds": { "$type": "SFML.Graphics.FloatRect, sfmlnet-graphics-2", "Left": 52.0, "Top": 72.0, "Width": 52.0, "Height": 72.0 }, "Name": "West-Idle" }, { "$type": "Astrendaria.Media.Matriceis.TextureMatrix, Astrendaria.Media", "X": 52.0, "Y": 72.0, "Width": 52.0, "Height": 72.0, "Bounds": { "$type": "SFML.Graphics.FloatRect, sfmlnet-graphics-2", "Left": 52.0, "Top": 72.0, "Width": 52.0, "Height": 72.0 }, "Name": "West-Idle" }, { "$type": "Astrendaria.Media.Matriceis.TextureMatrix, Astrendaria.Media", "X": 52.0, "Y": 144.0, "Width": 52.0, "Height": 72.0, "Bounds": { "$type": "SFML.Graphics.FloatRect, sfmlnet-graphics-2", "Left": 52.0, "Top": 144.0, "Width": 52.0, "Height": 72.0 }, "Name": "Right-Idle" }, { "$type": "Astrendaria.Media.Matriceis.TextureMatrix, Astrendaria.Media", "X": 52.0, "Y": 144.0, "Width": 52.0, "Height": 72.0, "Bounds": { "$type": "SFML.Graphics.FloatRect, sfmlnet-graphics-2", "Left": 52.0, "Top": 144.0, "Width": 52.0, "Height": 72.0 }, "Name": "Right-Idle" }, { "$type": "Astrendaria.Media.Matriceis.TextureMatrix, Astrendaria.Media", "X": 52.0, "Y": 216.0, "Width": 52.0, "Height": 72.0, "Bounds": { "$type": "SFML.Graphics.FloatRect, sfmlnet-graphics-2", "Left": 52.0, "Top": 216.0, "Width": 52.0, "Height": 72.0 }, "Name": "Up-Idle" }, { "$type": "Astrendaria.Media.Matriceis.TextureMatrix, Astrendaria.Media", "X": 52.0, "Y": 216.0, "Width": 52.0, "Height": 72.0, "Bounds": { "$type": "SFML.Graphics.FloatRect, sfmlnet-graphics-2", "Left": 52.0, "Top": 216.0, "Width": 52.0, "Height": 72.0 }, "Name": "Up-Idle" }, { "$type": "Astrendaria.Media.Matriceis.TextureMatrix, Astrendaria.Media", "X": 52.0, "Y": 0.0, "Width": 52.0, "Height": 72.0, "Bounds": { "$type": "SFML.Graphics.FloatRect, sfmlnet-graphics-2", "Left": 52.0, "Top": 0.0, "Width": 52.0, "Height": 72.0 }, "Name": "All-Idle" } ] } } Any and all help is appreciated because once this is fixed I can start refining and cleaning up the sprites code and it will be done, then I can move on to other systems. Link to comment Share on other sites More sharing options...
panda Posted June 28, 2018 Share Posted June 28, 2018 It's because they share values and reflection only recognizes a single variable as being associated with each actual value per what this thread says:https://www.experts-exchange.com/questions/21901419/Alias-for-enum-values.html  No good way to get around it. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now