以下是书中的一个抽像的单元格类,基类.
源码:
using System;
using System.Drawing;
namespace myblockcsharp
{
/// <summary>
/// CCell 的摘要说明。
/// </summary>
public class CCell
{
//单元的宽度
public int width;
//单元的位置
public Point Location=new Point(0,0); 
//构造函数1
public CCell()
{
 width = 1;
}
//构造函数2
public CCell(int CellWith)
{
width = CellWith;
}
//返回单元格所占矩形
public  Rectangle Rect
{
get
{
//单元的尺寸
Size sz = new Size(width, width);
//单元的矩形
Point pt =new Point(Location.X * width, Location.Y * width);
Rectangle rect = new Rectangle(pt, sz);
//返回矩形
return rect;
}
}
}
}这里面为什么是*(Location.X * width)不解.
Point pt =new Point(Location.X * width, Location.Y * width);

解决方案 »

  1.   

    这里的Location和一般的以像素为单位的X和Y,而是指以width为单位的X和Y。
    也就是以单元格为单位的X和Y,在2D游戏中这种方法用得很多。
      

  2.   

    这里的Location和一般的以像素为单位的X和Y不同,是指以width为单位的X和Y。 
    也就是以单元格为单位的X和Y,在2D游戏中这种方法用得很多。
      

  3.   

    谢谢你的指点,我是新手.
      我想应该这样理解:
      这里的Location是这个单元格宽度的单位,也就是这个单元格刻度的最小单位.#
      我当初理解错了,我以为是单元格在这个坐标系统里的起点位置.
    我没有分,不能给你,再次谢谢