Making a scrolling game and I want to make a boss level. How do I make a picturebox invisible for 10 seconds and then appear?

Recommended Answers

Is there perhaps a visible property you could set to false?You could use a timer to set it to true after 10 seconds.

Jump to Post

All 2 Replies

Is there perhaps a visible property you could set to false?You could use a timer to set it to true after 10 seconds.

I made a snippet for that part of the game using idea of just making a picturebox appear after 10 seconds. In the game it will appear once the player finishes that level.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
namespace vanishing_picturebox
{
    public partial class Form1 : Form
    {

        System.Timers.Timer timer;
        DateTime myLimit;
        public Form1()
        {
            InitializeComponent();
        }
        void Pic()
        {

            timer = new System.Timers.Timer();
            timer.Interval = 1000;
            timer.Elapsed += timer1_Tick;

            DateTime presenttime = DateTime.Now;
            DateTime vanish = myLimit.AddSeconds(1000);//AddMinutes(5);

            if (DateTime.Now > vanish)
            {
                pictureBox1.Visible = false;
            }
            else
                pictureBox1.Visible = true;
        }
        private void timer1_Tick(object sender, EventArgs e)
        {

            Pic();

        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.