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

0 favourites
  • 5 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • You can try and set a condition to check if the object on the top layer is overlapping the object beneath it.

  • 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.

  • 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".

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)