winforms - My program will not call the code that is to be executed in C# -


my code not make use of tmrmoving(timer) @ though timer on interval value of 100 there no reason can see i'm hoping it's 1 of days , simple. code follows,

using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.globalization; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms;  namespace games1 { public partial class form1 : form   {     public form1()     {         initializecomponent();     }     private void form1_mousedown(object sender, mouseeventargs e)     {         tmrmoving.enabled = true;         invalidate();     }      private void tmrmoving_tick(object sender, object value, type targettype,          object parameter, cultureinfo culture, eventargs e)     {          var curspoint = new system.drawing.point(cursor.position.x, cursor.position.y);         var playerpoint = new system.drawing.point(player.location.x, player.location.y);         var diff = new point(cursor.position.x - playerpoint.x, cursor.position.y - playerpoint.y);         var speed = math.sqrt(diff.x * diff.x + diff.y * diff.y);         if (speed > 10)         {             diff.x /= (int)(speed / 10);             diff.y /= (int)(speed / 10);         }         player.location = new system.drawing.point(player.location.x + diff.x, player.location.y + diff.y);     }   } } 

this link coding in image format if prefer way.

it seems me have 2 problems:

  1. your event handler signature doesn't match against what expected be. expected be:

    private void tmrmoving_tick(object sender, eventargs e) 
  2. is isn't possible compile broken event handler attached event. therefore seems me isn't assigned @ all. check existence of code doing (probably in designer.cs file):

    this.tmrmoving.tick += tmrmoving_tick; 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -