How do I make a sprite clickable once most of it is viewable

Get help using Construct 2

Post » Tue Apr 11, 2017 10:33 am

I am making a very simple proof-of-concept game that I will eventually turn into a tutorial for primary and secondary school students. It is a very basic escape the room game (no screen scrolling). The player has to "find" three special sprites in order for the game to end. I have been "hiding" these special sprites underneath other sprites by placing them on a lower layer. The sprites that are layered on top of the special sprites have the "DragDrop" and "solid" behaviours. I am using the "On left button clicked on <spritename>" event to ascertain whether the player has clicked one of the three special sprites. However, this is triggered when I click one of the sprites sitting on top of the special sprites... but I need the special sprites to be at least partially visible before triggering, otherwise the player will not realise that they have located the special sprite. Any ideas?

Colleen.
B
16
S
1
Posts: 4
Reputation: 608

Post » Tue Apr 11, 2017 10:55 am

Update!
I have managed to get it working reasonably well by adding conditions for not "cursor is not over" particular sprites (see link to code screenshot below). However, I have to hard code in each object and it isn't the most elegant solution and potentially difficult for beginners to grasp. Does anyone have any ideas for a more elegant solution.

E.g. can you do a test to see if the mouse is over anything appearing on a certain layer?
https://www.dropbox.com/s/24clder6buoj7qu/troubleshoot-construct2.png?dl=0
B
16
S
1
Posts: 4
Reputation: 608

Post » Tue Apr 11, 2017 11:00 am

You can try and set a condition to check if the object on the top layer is overlapping the object beneath it. :)
B
17
S
7
Posts: 277
Reputation: 2,514

Post » Tue Apr 11, 2017 11:19 am

Thank you for your reply. Is that solution any better than what I've come up with? You still have to hard code in each object that you want to check for. As many of the objects are drag and drop, this means potentially any object could overlap it. Am I missing something?

Also, it is okay if they overlap somewhat, I just want the player to purposefully select the object and I think ensuring that they have the mouse cursor not directly over any other sprite, is probably okay. I just wish there were a neater way of doing it than having to list each sprite separately.
B
16
S
1
Posts: 4
Reputation: 608

Post » Tue Apr 11, 2017 12:33 pm

How is this for a solution? I have all of the drag and drop items as multiple instances of one super sprite that has multiple frames (one for each drag and drop object). Then, I only need to test for each item whether the cursor is not over the super sprite object as well as whether the left button is clicked on the "special sprites".
B
16
S
1
Posts: 4
Reputation: 608


Return to How do I....?

Who is online

Users browsing this forum: David181 and 13 guests