我的Form2用外行术语来表示一个外部的迷你地图'关闭实际的迷你地图'在游戏中。
正如您在我的Form2上看到的那样,与“迷你地图”相比,我绘制的红点与我的播放器的位置不同。在游戏中,这是黄点。
在DebugView中,您可以看到我的字符X和Y位置(charX& charY)。
坐标以int x&在我的Form2类文件的函数中。
我的pictureBox1中的图像(上面当前示例图片中的图像)是从我的服务器中提取的(url =" http://randomspam.co/MAP/103000000.img/miniMap.canvas.png")。
以下代码包含了我目前的进展评论。
请注意,pictureBox1位置设置为0,0。
错误如下;
1)我的外部迷你地图上的红点位置!=我的角色在游戏中的迷你地图中的位置。
2)红点一直闪烁(出现和消失)
3)在pictureBox上显示的工具提示在揭示和揭露自身方面确实滞后。
如果有人知道如何帮助解决我目前的情况(因为我迷路了),请感谢任何事情。
感谢。
答案 0 :(得分:2)
好的,让我们将其分为主题:
1)红点位置:
在这里你必须将红点位置与新尺寸相匹配,之前已经多次回答过,请看这个 - > How can I transform XY coordinates and height/width on a scaled image to an original sized image?
2)Double Buffer停止闪烁:
public void DrawWhatever(Graphics graphics, int cx, int cy)
{
Graphics g;
Bitmap buffer = null;
buffer = new Bitmap([image width], [image height], graphics);
g = Graphics.FromImage(buffer);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
// Draw a circle.
Pen p = new Pen(Color.Red,1)
g.DrawEllipse(p,cx,cy,30,30); //example values
graphics.DrawImage(buffer, 0, 0);
g.Dispose();
}
3)工具提示:
检查双缓冲算法并告诉我
答案 1 :(得分:1)
从迷你地图中获取副本:
Bitmap bmp = new Bitmap(pictureBox1.Width, pictureBox1.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Bitmap bmpClone = new Bitmap(pictureBox1.Width, pictureBox1.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
Graphics objGraphics = Graphics.FromImage(bmpClone);
objGraphics.DrawImage(pictureBox1.Image, 0, 0);
objGraphics.Dispose();
bmp = (Bitmap)bmpClone.Clone();
pictureBox1.Image = bmp;
在任何无效之前执行:
Graphics objGraphics = Graphics.FromImage(bmp);
objGraphics.SmoothingMode = SmoothingMode.HighQuality;
objGraphics.DrawImage(bmpClone, 0, 0);
objGraphics.FillEllipse(Brushes.Red, cx, cy, 5, 5)
objGraphics.Dispose();
pictureBox1.Invalidate();
pictureBox1_Paint
瓦尔特