Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>here's what I did I hope this helps</p> <p>I created 2 Forms</p> <p>Form1 = where menu is (buttons), Form2 = the game level (i.e. level 1)</p> <p>then in Form2 I added an even LevelCompleted that will notify form1 that the player completed the level</p> <pre><code> //add this to form2 //the delegate public delegate void LevelCompleted(Int32 level); //the event public event LevelCompleted LevelCompletedEvent; </code></pre> <p>then on Form1 (the menu form) when you create an instance of Form2 (which has the event) subscribe to it and create a handler, in my case I added it after i created the instance of Form2</p> <pre><code> private void button1_CLick(object sender, EventArgs e) { Form2 level1 = new Form2(); level1.LevelCompletedEvent += new Form2.LevelCompleted(level1_LevelCompletedHandler); level1.Show(); } //and this is the handler method void level1_LevelCompletedHandler(int level) { //the logic for controlling the button states // the level parameter can be used to indicate what is the current level completed. if(level == 1) { button1.Enabled = false; button2.Enabled = true; } } </code></pre> <p>Note: that in Form2 (the game level) I created a field gameOver that can be used if he did not complete the game If in case he is permitted to go to next level, You must raise the event in this form to notify Form1 (the menu)<br> that he (the user) completed the level and Form1 will execute the method level1_LevelCompletedHandler(int level).</p> <p>I know this is not well explained but I hope I can give you an idea on the event. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload