Replace two objects with mouse

Just started using Construct 2? Post your questions here

Post » Mon Dec 19, 2016 9:55 pm

There are two objects - the player and the monster.

I want to change the place of the objects by clicking the left mouse button.

Image

As a result, the objects are reversed only when you click on the monster.
Why?

Image

It works if I alternating left and right mouse button.
B
6
Posts: 4
Reputation: 258

Post » Mon Dec 19, 2016 10:07 pm

Is there only ever one monster?
ImageImageImage
B
71
S
22
G
258
Posts: 3,791
Reputation: 143,198

Post » Mon Dec 19, 2016 10:20 pm

blackhornet wrote:Is there only ever one monster?


There are only two objects.
If you change the objects of the left mouse button - only works on the second object.
If the first object left mouse button, and the second object, right-click - it works on both objects.
B
6
Posts: 4
Reputation: 258

Post » Mon Dec 19, 2016 10:42 pm

:) The problem is that the second event isn't evaluated until after the first, so the first swaps the objects, then the second event runs, sees that you've now clicked on the MOVED object, so swaps them back again. What I'd suggest in this case is to place a Group after these two events, with the swap code in it and have the button events turn on the group, so that it runs. The Group should always turn itself off again. This ensures that the code only runs once.
ImageImageImage
B
71
S
22
G
258
Posts: 3,791
Reputation: 143,198

Post » Tue Dec 20, 2016 2:17 pm

Excuse me :(

can somebody give the code (or screenshot) as «swap two sprite by clicking the mouse on any of them» ?

Image
Image

it does not work and I do not understand what I need to do.
B
6
Posts: 4
Reputation: 258

Post » Tue Dec 20, 2016 3:26 pm

ImageImageImage
B
71
S
22
G
258
Posts: 3,791
Reputation: 143,198


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest