www.pudn.com > LINkSee.rar > BaseObject.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing.Imaging;
using System.Drawing;
namespace LinkSee
{
class BaseObject
{
protected Game game = null;
public int left = 0;//每个小图片定位参数
public int top = 0;
protected int width = 0;
protected int height = 0;
protected Image image = null;
protected ImageAttributes imageAttr = null;
protected int srcx = 0;//图像在源图像中的位置
protected int srcy = 0;
protected Boolean visible = false;
public bool Visible
{
get { return visible; }
set { this.visible = value; }
}
//**参数初始化
public BaseObject(Game game)//构造函数
{
this.game = game;
}
public BaseObject(Game game, Image image, ImageAttributes imageAttr)//重载构造函数 /
: this(game)
{
this.image = image;
this.imageAttr = imageAttr;
}
public virtual void process() { }
public virtual void Draw(Graphics gc)
{
if (this.visible)
{
gc.DrawImage(this.image, new Rectangle(this.left, this.top, this.width, this.height), this.srcy, this.srcx, this.width, this.height,
GraphicsUnit.Pixel, this.imageAttr);
}
}
public virtual void Reset() { }
public void move(int left, int top)
{
this.left = left;
this.top = top;
}
public void Resize(int height, int width)
{
this.height = height;
this.width = width;
}
public void show()//显示对象
{
this.visible = true;
}
public void hide()//隐藏对象
{
this.visible = false;
}
}
}