C# 指向客户端的指针不太正常。(中的错误详细信息。)
我和我的一个朋友正在为一次班级考试做一个塔防。我想我会使用“PointToClient”来获取光标的位置,以便在我们想要放下塔时随塔发送。但它不太管用。我不断得到错误: “Vp.PlaceTower”不包含“PointToClient”的定义,并且找不到接受“Vp.PlaceTower”类型的第一个参数的扩展方法“PointToClient”(是否缺少using指令或程序集引用?) 守则如下:C# 指向客户端的指针不太正常。(中的错误详细信息。),c#,.net,winforms,gdi+,C#,.net,Winforms,Gdi+,我和我的一个朋友正在为一次班级考试做一个塔防。我想我会使用“PointToClient”来获取光标的位置,以便在我们想要放下塔时随塔发送。但它不太管用。我不断得到错误: “Vp.PlaceTower”不包含“PointToClient”的定义,并且找不到接受“Vp.PlaceTower”类型的第一个参数的扩展方法“PointToClient”(是否缺少using指令或程序集引用?) 守则如下: using System; using System.Collections.Generic; usi
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);
}
}
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用系统文本;
使用系统图;
使用System.Windows.Forms;
使用系统组件模型;
使用系统数据;
名称空间Vp
{
职业:游戏世界
{
私有列表塔=新列表();
专用点游标;
私人点位;
私人点;
公众大厦()
{
cursorPos=this.PointToClient(Cursor.Position);
}
}
}
指向客户端
是属于类System.Windows.Forms.Control
的方法。GameWord继承这个类吗?你的例外说明得很清楚。
让游戏世界继承控制权,你就会解决这个问题。我以前用过这个方法,所以我只是检查了一下使用情况,但没有一个有“Forms.Control”。如果这就是我所需要做的,我会很高兴:)