简体   繁体   中英

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

I hope I have solved your problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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