kylepulver / Otter

2d game making framework built on top of SFML.Net
MIT License
54 stars 10 forks source link

CS0649: Field 'ColorTween.hue' is never assigned to, and will always have its default value 0 #2

Closed Mellorison closed 4 years ago

Mellorison commented 4 years ago

Hi. I keep getting this error in the cache whenever I try to run the code below:

Internalerr

`using Otter; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace PlayerSessions { class PlayerSessions { static void Main(string[] args) { // Create a game var game = new Game("Player Sessions"); // Name the game folder for exporting session data. game.GameFolder = "PlayerSessionDemo";

        // Add a new session to the game for Player 1.
        var session = game.AddSession("TestPlayer1");

        // Import any data. If no data found, none will be loaded.
        session.Data.Import();

        // Load data, or set default values.
        // Using strings for keys here, but you can also use Enums!
        session.Data.GetIntOrDefault("LevelsUnlocked", 0);
        session.Data.GetStringOrDefault("LeaderboardName", "Player");
        session.Data.GetBoolOrDefault("InvertedControls", false);
        session.Data.GetStringOrDefault("PlayerColor", "FF0000");
        session.Data.GetFloatOrDefault("StartPosition", 0.25f);

        // Export the data to a semi-encrypted file.
        session.Data.Export();

        // Configure the Controller for the player session.
        // Add a "Left" button
        session.Controller.AddButton("Left");
        // Set the button to respond to the A key.
        session.Controller.Button("Left").AddKey(Key.A);

        // Add a "Right" button
        session.Controller.AddButton("Right");
        // Set the button to respond to the D key.
        session.Controller.Button("Right").AddKey(Key.D);

        // Add a new session to the game for Player 2.
        session = game.AddSession("TestPlayer2");

        // Import any data. If no data found, none will be loaded.
        session.Data.Import();

        // Load data, or set default values.
        // Using strings for keys here, but you can also use Enums!
        session.Data.GetIntOrDefault("LevelsUnlocked", 0);
        session.Data.GetStringOrDefault("LeaderboardName", "Player");
        session.Data.GetBoolOrDefault("InvertedControls", false);
        session.Data.GetStringOrDefault("PlayerColor", "0000FF");
        session.Data.GetFloatOrDefault("StartPosition", 0.75f);

        // Export the data to a semi-encrypted file.
        session.Data.Export();

        // Configure the Controller for the player session.
        // Add a "Left" button
        session.Controller.AddButton("Left");
        // Set the button to respond to the Left key.
        session.Controller.Button("Left").AddKey(Key.Left);

        // Add a "Right" button
        session.Controller.AddButton("Right");
        // Set the button to respond to the Right key.
        session.Controller.Button("Right").AddKey(Key.Right);

        // Create a Scene.
        var scene = new Scene();
        // Add a Player Entity for each session.
        scene.Add(new Player(game.Session("TestPlayer1")));
        scene.Add(new Player(game.Session("TestPlayer2")));

        // Start the Game.
        game.Start(scene);
    }
}

class Player : Entity
{
    // Create a test image.
    Image image = Image.CreateRectangle(40, Color.White);
    // The Session that this Entity will reference.
    Session session;

    public Player(Session session) : base()
    {
        // Keep track of the Session passed in by the constructor.
        this.session = session;

        // Set the starting position.
        // Using Game.Instance here because the Entity doesn't have a reference to the Game yet.
        X = Game.Instance.HalfWidth;
        Y = Game.Instance.Height * session.Data.GetFloat("StartPosition");

        // Add the image.
        AddGraphic(image);
        // Center the origin of the image.
        image.CenterOrigin();
        // Set the image color from the Session data. 
        // Using a string for the key, but you can also use Enum!
        image.Color = new Color(session.Data.GetString("PlayerColor"));
    }

    public override void Update()
    {
        base.Update();

        // Use the Session controller to control the movement.
        // Using a string for the key, but you can also use Enum!
        if (session.Controller.Button("Left").Down)
        {
            X -= 3;
        }
        if (session.Controller.Button("Right").Down)
        {
            X += 3;
        }
    }
}

}`

bPoller2810 commented 4 years ago

copy pasting your code into a blank project with otter and VS19 up to date runs as expected. -Are your tools up to date? -What OS and machine are you using? -What project type did you create? ( i used 4.7.2)

Mellorison commented 4 years ago

Is it mandatory for me to use VS19? The surprising thing about this is that this code runs without any problems in VS15 .... I'm currently using VS17 and that's where I'm experiencing this error.
I am running windows 10 OS on a Dell xps 13. I created a .NETconsoleApp project type... v4.5.2

bPoller2810 commented 4 years ago

Since i have no installed previous(15 and 17) versions on any of my develop machines i can not say if this is the "problem".

could you host your complete project on github? on the first glance it seems all fine. but the devil lies in the detail maybe.

kylepulver commented 4 years ago

I haven't had a chance to look at this in detail yet, but it looks like the texture it's trying to load from a stream isn't there for some reason, but as far as I know it shouldn't even be hitting that code with what the example does. if you comment out AddGraphic(image); does it still blow up?

the error message about the color value might have something to do with assigning a player color from the session data, but that appears to just be a warning and unrelated to the actual crash.

Mellorison commented 4 years ago

Since i have no installed previous(15 and 17) versions on any of my develop machines i can not say if this is the "problem".

could you host your complete project on github? on the first glance it seems all fine. but the devil lies in the detail maybe.

Alright. I'll do that.

Mellorison commented 4 years ago

I haven't had a chance to look at this in detail yet, but it looks like the texture it's trying to load from a stream isn't there for some reason, but as far as I know it shouldn't even be hitting that code with what the example does. if you comment out AddGraphic(image); does it still blow up?

the error message about the color value might have something to do with assigning a player color from the session data, but that appears to just be a warning and unrelated to the actual crash.

I Tried commenting out 'AddGraphic(image)', but to no avail. Also tried rebuilding the solution and now this is happening :

AddP