Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何让图片框在触摸时显示消息框 private void GameScreen\u加载(对象发送方,事件参数e) { } public void timer1_Tick(对象发送方,事件参数e) { 整数时间=1; timer1.Start(); 时间间隔=1; 时间+=1; } 私有无效字符\u单击(对象发送者,KeyEventArgs e) { } 私有无效图片单击(对象发送方,事件参数e) { } 私有void GameScreen_KeyDown(对象发送方,KeyEventArgs e) { int x=CharacterUser.Location.x; int y=CharacterUser.Location.y; 如果(e.KeyCode==Keys.Right)x+=4; 如果(e.KeyCode==Keys.Left)x-=4; CharacterUser.Location=新点(x,y); } 公共无效块单击(对象发送者,事件参数e) { timer1.Stop(); } private void IsTouching(PictureBox CharacterUser,PictureBox块) { if(CharacterUser.Location.X+CharacterUser.Width_C#_Visual Studio - Fatal编程技术网

C# 如何让图片框在触摸时显示消息框 private void GameScreen\u加载(对象发送方,事件参数e) { } public void timer1_Tick(对象发送方,事件参数e) { 整数时间=1; timer1.Start(); 时间间隔=1; 时间+=1; } 私有无效字符\u单击(对象发送者,KeyEventArgs e) { } 私有无效图片单击(对象发送方,事件参数e) { } 私有void GameScreen_KeyDown(对象发送方,KeyEventArgs e) { int x=CharacterUser.Location.x; int y=CharacterUser.Location.y; 如果(e.KeyCode==Keys.Right)x+=4; 如果(e.KeyCode==Keys.Left)x-=4; CharacterUser.Location=新点(x,y); } 公共无效块单击(对象发送者,事件参数e) { timer1.Stop(); } private void IsTouching(PictureBox CharacterUser,PictureBox块) { if(CharacterUser.Location.X+CharacterUser.Width

C# 如何让图片框在触摸时显示消息框 private void GameScreen\u加载(对象发送方,事件参数e) { } public void timer1_Tick(对象发送方,事件参数e) { 整数时间=1; timer1.Start(); 时间间隔=1; 时间+=1; } 私有无效字符\u单击(对象发送者,KeyEventArgs e) { } 私有无效图片单击(对象发送方,事件参数e) { } 私有void GameScreen_KeyDown(对象发送方,KeyEventArgs e) { int x=CharacterUser.Location.x; int y=CharacterUser.Location.y; 如果(e.KeyCode==Keys.Right)x+=4; 如果(e.KeyCode==Keys.Left)x-=4; CharacterUser.Location=新点(x,y); } 公共无效块单击(对象发送者,事件参数e) { timer1.Stop(); } private void IsTouching(PictureBox CharacterUser,PictureBox块) { if(CharacterUser.Location.X+CharacterUser.Width,c#,visual-studio,C#,Visual Studio,我不知道为什么当我使用GameScreen_键中的代码移动其中一个图片框时,它会接触到另一个图片框,消息框不会出现,并且消息文本中无法识别计时器,即使我在timer1_勾中定义了计时器,任何帮助都将不胜感激 提前谢谢 您何时/何地调用isTouch()?您的目标是什么:Winforms、WPF、ASP。。?始终正确标记您的问题!-定时器1.Interval=1这是一个不切实际的值。分辨率约为20-30毫秒,而不是1毫秒!也。滴答声就是事件。在那里启动计时器没有用!!那里的所有(或至少)代码都应该

我不知道为什么当我使用GameScreen_键中的代码移动其中一个图片框时,它会接触到另一个图片框,消息框不会出现,并且消息文本中无法识别计时器,即使我在timer1_勾中定义了计时器,任何帮助都将不胜感激


提前谢谢

您何时/何地调用
isTouch()
?您的目标是什么:Winforms、WPF、ASP。。?始终正确标记您的问题!-<代码>定时器1.Interval=1这是一个不切实际的值。分辨率约为20-30毫秒,而不是1毫秒!也。滴答声就是事件。在那里启动计时器没有用!!那里的所有(或至少)代码都应该移到其他地方。。最有可能的情况是,你想搬到那里,然后进行测试。。
    private void GameScreen_Load(object sender, EventArgs e)
    {

    }

    public void timer1_Tick(object sender, EventArgs e)
    {
        int Time = 1;
        timer1.Start();
        timer1.Interval = 1;
        Time += 1;

    }

    private void Character_Click(object sender, KeyEventArgs e)
    {

    }

    private void pictureBox1_Click(object sender, EventArgs e)
    {

    }

    private void GameScreen_KeyDown(object sender, KeyEventArgs e)
    {
         int x = CharacterUser.Location.X;
         int y = CharacterUser.Location.Y;

        if (e.KeyCode == Keys.Right) x += 4;
        else if (e.KeyCode == Keys.Left) x -= 4;

        CharacterUser.Location = new Point(x, y);
    }

    public void Block_Click(object sender, EventArgs e)
    {
        timer1.Stop();
    }
    private void IsTouching(PictureBox CharacterUser, PictureBox Block)
    {
        if (CharacterUser.Location.X + CharacterUser.Width < Block.Location.X)
            MessageBox.Show("Continue? You survived for", +Time, "You failed", MessageBoxButtons.YesNo);
        if (Block.Location.X + Block.Width < CharacterUser.Location.X)
            MessageBox.Show("Continue? You survived for", +Time, "You failed", MessageBoxButtons.YesNo);
        if (CharacterUser.Location.Y + CharacterUser.Height < Block.Location.Y)
            MessageBox.Show("Continue? You survived for", +Time, "You failed", MessageBoxButtons.YesNo);
        if (Block.Location.Y + Block.Height < CharacterUser.Location.Y)
            MessageBox.Show("Continue? You survived for", +Time, "You failed", MessageBoxButtons.YesNo);

    }


    }
}