2016-09-01 7 views
0

私は小さな学校プロジェクトのためにVisual Studio 2015 C#でflappybirdを再作成しようとしています。しかし、何らかの理由で私はこのエラーを受け取り、私は本当に修正できません。私はflappybirdを作成する方法についてのチュートリアルに従っていますが、チュートリアルを作成している人は、VB.netのHeres the YT Linkと私のコードの下に作ろうとしています。パイプがあるものの https://www.youtube.com/watch?v=tnjdMbdEzMoc#Flappybird "メソッドのように呼び出すことのできないメンバーは使用できません"

public partial class Form10 : Form 
{ 

    int gravity = 1; 
    int yspeed = 0; 
    PictureBox[,] Pipe; 

    public Form10() 
    { 
     InitializeComponent(); 
    } 

    private void gameTimer_Tick(object sender, EventArgs e) 
    { 
     int i; 
     this.yspeed += this.gravity; 
     bird.Top += this.yspeed;    
    } 
    private void inGameKeyDown(object sender, KeyEventArgs e) 
    { 
     if (e.KeyCode == Keys.Space) 
     { 
      this.yspeed = -15; 
     } 
    } 
    private void pausePlayToolStripMenuItem_Click(object sender, EventArgs e) 
    { 
     if (gameTimer.Enabled == true) 
     { 
      gameTimer.Enabled = false; 
     } 
     else 
     { 
      if (gameTimer.Enabled == false) 
      { 
       gameTimer.Enabled = true; 
      } 
     } 
    } 
    private void restartToolStripMenuItem_Click(object sender, EventArgs e) 
    { 

    } 
    private void startGame_Click(object sender, EventArgs e) 
    { 
     if (gameTimer.Enabled == false) 
     { 
      gameTimer.Enabled = true; 
      startGame.Enabled = false; 
     } 
    } 
    private void CreatePipes(int number) 
    { 
     int i = 0; 
     for (i = 0; (i <= number); i++) 
     { 
      var temp = new PictureBox(); 
      this.Controls.Add(temp); 
      temp.Width = 50; 
      temp.Height = 370; 
      temp.BorderStyle = BorderStyle.FixedSingle; 
      temp.BackColor = Color.Red; 
      temp.Top = 50; 
      temp.Left = (2 * 200) + 300; 
      Pipe(i) = temp; 
      Pipe(i).Visable = true; 
     } 
    } 
    private void Form10_Load(object sender, EventArgs e) 
    { 
     gameTimer.Enabled = true; 
     CreatePipes(1); 
    } 
} 

}

+1

エラーが発生した行はありますか。 –

+0

おそらく 'Pipe(i)'にあります。 'Pipe'は2次元配列なので、' Pipe [x、y] 'のようなものでなければなりません。' x'と 'y'は次元に依存しますが、' Pipe' 。 –

+0

VB.NETとC#の構文が混在しています。 –

答えて

1

あなたが見ている問題は、

Pipe(i) = temp; 
Pipe(i).Visable = true; 

あなたは配列としてパイプにアクセスしようとしている場合は、構文はPipe[i]あるラインであります2dの配列でなければなりません。Pipe[i,j]ここで、jは別のものです。

また、Visibleのスペルが間違っています。

+0

さて、私は目に見える綴りが間違っていることを知っています。しかし、「パイプ(i)」を認識しなかったので、それを自動的に修正することはできませんでした。ご協力いただきありがとうございます。私は修正プログラムを適用しようとしたと働いた。今私は何かのために "j"を使用する必要があります:) – Minik

+0

@Minik、良い、ハッピーコーディング。 – js441

関連する問題