【发布时间】:2014-04-26 03:20:52
【问题描述】:
对于一个项目,我正在制作一个游戏,其中有一个滚动地图。地图左右移动并在图片框中重新绘制,以便我可以在小图片框中拥有大地图。地图的顶部是透明的,因此我可以稍后更改天空颜色。但是,当我移动地图时,透明部分会出现故障。
如您所见,树线上方的所有内容都被拉伸了,这是因为这是透明度开始的地方。图片框的父级是窗体,窗体是浅蓝色的,这就是为什么背景是浅蓝色的。
这是我将图片移动/重绘到图片框的代码:
private void timerTick_Tick(object sender, EventArgs e)
{
move();
//Draws new portion of the map
g.DrawImage(image, new Rectangle(0, 0, pbMap.Width, pbMap.Height), new Rectangle(imageX, imageY, pbMap.Width, pbMap.Height), GraphicsUnit.Pixel);
//Refreshes
pbMap.Image = bmp;
}
private void move()
{
//Right arrow events
if (right)
{
imageX += mapSpeed;
//Makes sure the picture stays within borders
if (imageX >= (imageWidth - pbMap.Width))
{
imageX = imageWidth - pbMap.Width;
}
}
//Left arrow events
if (left)
{
imageX -= mapSpeed;
//Makes sure the picture stays within borders
if (imageX <= 0)
{
imageX = 0;
}
}
}
谁能帮忙解释一下这个故障?
【问题讨论】:
标签: c# transparency picturebox