0

色が変化するスパイラルを作成する簡単なプロセスを作成しているので、さまざまな変数をテストし、C# を学習できます。ただし、コードに問題は見つかりませんが、デバッグすると空白のブルー スクリーンが返されます。誰でも問題を見つけることができますか。ボール ポイントに必要な変数を含むすべてのコードを次に示します。

    Vector2 Tripos;
    List<Color> Tricol;
    List<Vector2> datatripos;
    List<int> count;
    Color currentcol;
    float Tri_angle;
    float Triscale;
    int Tri_speed;
    int screenwidth;
    int screenheight;
    int addtocount;
    Texture2D Ball;
    int colourchangespeed;

 protected override void LoadContent()
    {
        // Create a new SpriteBatch, which can be used to draw textures.

        Tripos = new Vector2(screenwidth / 2, screenheight / 2);
        Triscale = 1;
        Tri_angle = 1;
        Tri_speed = 1;
        colourchangespeed = 1;
        Ball = Content.Load<Texture2D>("ball");
        currentcol = new Color(0, 0, 0);
        addtocount = 0;
        datatripos = new List<Vector2>();
        Tricol = new List<Color>();
    }

これは update メソッドによって呼び出されます。

        private void Posgen()
    {

        Tripos.X += (float)Math.Sin(MathHelper.ToRadians(Tri_angle))*Tri_speed;
        Tripos.Y += (float)Math.Cos(MathHelper.ToRadians(Tri_angle))*Tri_speed;
        Tri_angle++;
    }
    private void colchanger()
    {
        currentcol.R += (byte)colourchangespeed;
        if (currentcol.R == 255)
        {
            currentcol.R = 0;
            currentcol.G += (byte)colourchangespeed;
        }
        if (currentcol.G == 255)
        {
            currentcol.G = 0;
            currentcol.B += (byte)colourchangespeed;
        }
        if (currentcol.B == 255)
        {
            currentcol.B = 0;
        }
    }
    private void dataadd()
    {
        addtocount++;
        Tricol.Add(currentcol);
        datatripos.Add(Tripos);
        count.Add(addtocount);
    }

draw メソッドによって呼び出されます。

    private void drawtri()
    {
        foreach (Vector2 data in datatripos)
        {
            spriteBatch.Draw(Ball, data, null, currentcol, 0, new Vector2(5, 5), Triscale, SpriteEffects.None, 0);
        }
    }

完全なコードが必要な場合は、事前にお問い合わせください。使用しない変数がいくつかありますが、後で使用するつもりなので無視してください。

前もって感謝します。

モナ君。

4

1 に答える 1