Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace PBCollide
- {
- public partial class Form1 : Form
- {
- Rectangle pb1;
- Rectangle pb2;
- public Form1()
- {
- InitializeComponent();
- pictureBox2.LocationChanged += new EventHandler(pictureBox2_LocationChanged);
- }
- void pictureBox2_LocationChanged(object sender, EventArgs e)
- {
- if (pb1.IntersectsWith(pb2))
- {
- MessageBox.Show("test");
- }
- }
- private void button4_Click(object sender, EventArgs e)
- {
- Point newloc = pictureBox2.Location;
- newloc.X -= 10;
- pictureBox2.Location = newloc;
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- pb1 = new Rectangle(pictureBox1.Location, pictureBox1.Size);
- pb2 = new Rectangle(pictureBox2.Location, pictureBox2.Size);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement