Connecting two points (Matching Game)

I have point A that I want to connect and a thread appears to point B

Line appears

After connecting, there is a button to verify the correctness of the answer.

What’s your question? Do you want to know how to link the two points? How to draw a line between the two? How to confirm the connection is correct? How are the two points selected - drag & drop, click some other way?

1 Like

I want to know how to connect two points? And how do I draw a line between them?
That is, when I click on the first point and drag, a line appears.
Then the line is placed at the second point.
A connection will appear between the two points.
Then click the button to confirm the connection.
Please help me with a simple example.

@MrMen Does it work with GDevelop 5?

Where are the creative and genius programming and design? :wink:

HI, you can do this with the SHAPE PAINTER object.
create 2 scene vars (currentDotX and currentDotY).
create another scene var (DrawLine. it should be a boolean)
If a point is clicked on, set the 2 scene variables to the x pos and y pos of the dot clicked on.
Another event should be if mouse up, set Draw Line to false, and if mouse down, set draw line to true.
Then using another event sheet, If draw line is true => draw a line from currentDotX and currentDotY, toward CursorX and CursorY.

BE SURE TO SET “clear rendered image between each frame” to true when creating the shape painter object, in its properties…

1 Like

@dskyle7
I’m not proficient in this program. It’s difficult.
Here’s a simple example of what you said.

Ok, should I send a screenshot of it

1 Like

@dskyle7 Thank you for your kind reply.

Hi, This took my time to create :frowning_face:, but im just going to show you.
First Prepare a scene like this


For the black dots, give them this variables

Then Click on each Individual dot on the left, and give them IDs 1, 2, 3, 4 respectively.
For the dots on the right, give them IDs 11, 22, 33, 44 depending on which of them are the correct match to each other.
My own setup would be 33, 11, 44, 22. because corresponding match is on the other row in the board.

Then create these scene variables


The summary structure has only 4 children, Increase this to a number like 9 if you want 9 matches.

Then add this first

,

Followed by this


And Finally this

Press space bar to confirm connection, wrongly connected balls will be deleted

Then it should work.

3 Likes

Thank you so much, genius. I wish you a happy new year always. :heart_eyes: