2011-12-22 84 views
0

我工作的一个塔防的一类考试连同我的一个朋友。而且我想我会用“PointToClient”要得到光标所在的位置与塔派当过,我们希望把它放下。但它不太有效。我不断收到错误:PointToClient不起作用。 (中错误的详细信息。)

'Vp.PlaceTower'未包含'PointToClient'的定义,也没有找到接受'Vp.PlaceTower'类型的第一个参数的扩展方法'PointToClient'(您是否缺少一个使用指令或程序集引用?)。

的代码如下;

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); 


    } 
} 
} 

回答

1

PointToClient是属于类System.Windows.Forms.Control的方法。 GameWord会继承这个类吗?你的例外是非常明显的。 让游戏世界继承的控制,你会解决这个问题。

+0

我以前这种方法使用的,所以我只是通过usings检查,但他们都没有“Forms.Control”如何过,如果这是所有我需要做的,我会相当高兴:) – Etarnalazure 2011-12-22 00:43:25

+0

我们走吧,谢谢你的帮助:) – Etarnalazure 2011-12-22 00:49:03

+0

很高兴我可以帮助:) – 2011-12-22 01:00:10