KeyPressEventHandler() создает исключение
System.ArgumentException: "Delegate to an instance method cannot have null 'this'."
namespace RFDW
{
public partial class GameForm : Form
{
public GameForm()
{
InitializeComponent();
Player player = (Player)Game.sbj[0, Game.player_id];
label1.Location = new Point(1, 15);
Map.Build();
this.KeyPress += player.Move; // исключение System.ArgumentException: "Delegate to an instance method cannot have null 'this'."
label1.Text = Map.Render();
}
}
}
namespace RFDW
{
class Player : Creature
{
//settings
public new string name = "Player";
public new string art = "☺";
public int stamina = 10/10;
public new int speed = 5;
public void Move(Object sender, KeyPressEventArgs e)
{
// Collision
Collision(1);
// Movement
if (e.KeyChar == 'd' && !right_col) ++x; // Right
if (e.KeyChar == 'a' && !left_col) --x; // Left
if (e.KeyChar == 's' && !down_col) ++y; // Down
if (e.KeyChar == 'w' && !up_col) --y; //Up
if (stamina < 1) stamina +=1 / 10;
}
public Player(int x, int y) : base(x, y)
{
this.x = x;
this.y = y;
}
}
}
Пожалуйста помогите.
Источник: Stack Overflow на русском