简体   繁体   English

将图片添加到移动图片框中

[英]adding picture to moving pictureBoxes

I am developing a game, where we have a spaceship, rockets, and some picture boxes showing the enemy. 我正在开发一款游戏,我们有一个宇宙飞船,火箭和一些展示敌人的图片框。 The goal is to kill the enemy with rockets. 目标是用火箭杀死敌人。

I used this code for the picture boxes but this won't make a good result. 我将这段代码用于图片框,但这不会有好结果。

foreach (Control element in ptb_backGround.Controls)
{
    if (element is PictureBox && element.Name != "ptb_spaceShip")
    {
        Image enimisPic = Properties.Resources.Alien_displeased_icon;
        element.BackColor = Color.Transparent;
        ptb_backGround.Controls.Add(element);
        element.BackgroundImage = enimisPic;
        element.BackgroundImageLayout = ImageLayout.Stretch;
    }
}

Screenshot, with a placeholder / rectangle 屏幕截图,带有占位符/矩形
在此输入图像描述

Screenshot, with the actual image 屏幕截图,包含实际图像
在此输入图像描述

I had this problem once too and i tried many solutions, They al worked form me but the did flicker when moving. 我曾经遇到过这个问题而且我尝试了很多解决方案,他们在我身上工作但是移动时闪烁了。 except this with this control . 除了这个控制

But I would not use forms is not suitable for making games. 但我不会使用表格不适合制作游戏。 I would use XNA or Unity if I were you 如果我是你,我会使用XNA或Unity

I hope I have solved your problem 我希望我已经解决了你的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM