i’m working on a tower defence for a class exam together with a friend of mine. And i figured i would use “PointToClient” To get the positions of the cursor to send with the tower when ever we want to put it down. But its not quite working. I keep getting the error:
‘Vp.PlaceTower’does not contain a definition for ‘PointToClient’ and no extension method ‘PointToClient’ accepting a first argument of type ‘Vp.PlaceTower’ could be found (Are you missing a using directive or an assembly reference?).
The code is as follows;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Data;
namespace Vp
{
class PlaceTower : GameWorld
{
private List<Tower> towers = new List<Tower>();
private Point cursorPos;
private Point position;
private Point oldCursorPos;
public void PlaceTower()
{
cursorPos = this.PointToClient(Cursor.Position);
}
}
}
PointToClientis a method that belongs to the classSystem.Windows.Forms.Control. Does GameWord inherit this class? Your exception is very explanatory.Make GameWorld inherit Control and you will solve this.