开发者

'object' does not contain a constructor that takes 3 arguments

I'm trying my hand a开发者_JAVA百科t generating spherical terrain in XNA 4.0, and am using an Icosahedron to achieve a sphere with evenly-distributed vertices. I'm fairly new to Xna, and I'm running into this problem trying to create a class that will handle defining all the vertices for the sphere.

here's the code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Icosahedron_Test
{
    class Icosahedron
    {

        public Icosahedron(int radius, int refinement, Vector3[] vertices)
            : base(radius, refinement, vertices)
        {
        }


    }
}

also, if anyone knows how to create an icosahedron, or can direct me to a tutorial, I'd be really grateful XD


In your code example, you are defining a new class called Icosahedron.

The code you provided is called a Constructor, which is a special method that is used to instantiate new objects.

public Icosahedron(int radius, int refinement, Vector3[] vertices)
        : base(radius, refinement, vertices)

When writing

: base( .... )

You are attempting to call a base call of the current class you're defining.

C# supports a mechanism called Inheritance, which allows extending an object's behavior by extending another class. This can be used for adding/overriding some of the parent object's behavior and abilities.

In C#, all objects are derived from System.Object, and so, in your code you are attempting to call System.Object's constructor with 3 parameters, but this constructor method does not exist for System.Object.

You need to get a good reading on C# to get a grip on the basics :)


Your Icosahedron inherits object.

As the error message clearly states, you can't call base(...), since object doesn't have such a constructor.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜