Hallo,
ich bin gerade dabei ein Spiel zu programmieren. Als Hilfe habe ich das Buch von O'Reilly "Learning XNA 4.0". Dort sind ein paar Tutorials, die ich Schritt für Schritt nachbaue.
Noch kurz erwähnt: Ich bin absoluter C# Neuling und habe auch relativ wenige Programmierkenntnisse.
Nun zu meiner Frage:
Kann mir einer diesen Code mal etwas genauer erklären (vor allem, was das THIS genau macht):
|
C#-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
public Sprite(Texture2D textureImage, Vector2 position, Point frameSize,
int collisionOffset, Point currentFrame, Point sheetSize, Vector2 speed, string collisionCueName)
: this(textureImage, position, frameSize, collisionOffset, currentFrame, sheetSize, speed, defaultMillisecondsPerFrame, collisionCueName)
{
}
public Sprite(Texture2D textureImage, Vector2 position, Point frameSize,
int collisionOffset, Point currentFrame, Point sheetSize, Vector2 speed, int millisecondsPerFrame, string collisionCueName)
{
this.textureImage = textureImage;
this.position = position;
this.frameSize = frameSize;
this.collisionOffset = collisionOffset;
this.currentFrame = currentFrame;
this.sheetSize = sheetSize;
this.speed = speed;
this.collisionCueName = collisionCueName;
this.millisecondsPerFrame = millisecondsPerFrame;
}
|
Ich habe eine Klasse "Sprite" erstellt. Und ich habe 2 Konstruktoren erstellt. Der Unterschied der beiden Konstruktoren ist "milliseconds" und "defaultMilliseconds".
Leider verstehe ich aber nicht so genau, was ich mit dem this Anfangen sollte!
Könnt ihr mir das kurz und knapp erklären?
Vielen Dank
/EDIT:
mit this.speed = speed erstelle ich eine Instanz der Variable speed? :-) Hab ich das richtig verstanden?
P.S.: Ich weiß gerade nicht, wieso der code keine Zeilenumbrüche macht! Sorry