Answer the question
In order to leave comments, you need to log in
If the object is in contact with black, then output to the console?
Hello!
Program: visual studio (winforms).
Please tell me how to insert this code:
if (obj.intersects(pictureBox2) && pictureBox1.color == Color.black) {
}
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;
namespace CTDk {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
//сюда
Console.WriteLine("Hello World!");
}
}
}
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;
namespace CTDk {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
if (obj.intersects(pictureBox2) && pictureBox1.color == Color.black) {
Console.WriteLine("Hello World!");
}
}
}
}
Answer the question
In order to leave comments, you need to log in
First, a small lyrical digression.
If your question is related to any of the previous ones, then be sure to provide a link to it so that you can understand the context.
Now to the question.
Your object ( obj ) is a PictureBox , a control that, not surprisingly, does not have its own intersects method .
But you can use the Bounds property to get the location and dimensions of your objects:
if(pictureBox1.Bounds.IntersectsWith(pictureBox2.Bounds))
{
// put your code here
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question