How do I click through transparency?

0 favourites
  • 12 posts
From the Asset Store
High quality sound effect pack, in the following categories: Simple, negative, pozitive
  • As in the title, is there any way to make mouse clicks pick the next layer if the first layer is completely (Or even partially) transparent?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I would be interested in that as well if that's possible, as I have to lock and un-lock my "gui" layer all the time

  • I should probably elaborate, I'm trying to recreate some of Space Station 13 just for practice before I move on to my main game idea,

    Here is the .capx:

    dropbox.com/s/atn4u9cjcgrtuuo/Space%20Station%2013_Not%20working.capx

    I've only just started making the game. What I want to do, is to be able to is to click on the different body parts of the human shape in the bottom right corner (it's only there when you launch the game.)

    In order to do this, without doing something overly complex with math, I created the Zone_Selection object type, to show which body part is selected. I then created a new object type with hit boxes for every body part you can create. When the eyes are clicked, I want to highlight the eyes.

    The only problem is, that every image of the hit boxes are 32x32, and the when you click anywhere on the Zone_Selection sprite, the topmost hit box is selected, even if you don't click where the would-be-visible part of the hitbox.

    Anyway, if you download the .capx file, and run the game, then click the target selector in the bottom right corner, you'll quickly see that no matter where you click on it, the eyes will always become selected.

    Any help would be much appreciated! <img src="smileys/smiley1.gif" border="0" align="middle" />

  • It's because your collision polygon for the eyes takes up the full image. C2 thinks you're clicking on them because you are actually doing so. You need to make the collision polygon fit the artwork. You did the same thing with Zone_Arm_Right and a few others. You should actually go through and check on all your collision polygons; some of them, like the left arm, are pretty weird.

  • I don't get it. What is weird about having every sprite be the same resolution when you want everything to be placed in a grid on the screen?

    The painted part of the left arm fits perfectly fine with the artwork, so I don't see why C2 shouldn't be smart enough to know what to select.

    What I'm asking, is if there is some way of making the mouse selection smarter.

    No matter what I do, the collision box will always be shaped like a box, so it won't fit very well with the items I'm making.

    For example, If I went a head and placed 3 different shaped items exactly on top of each other, and I want my character to pick up an item on mouse click, how would I make it pickup the item that you're clicking on, rather than picking up the top most item?

    I wouldn't want a dropdown menu to be required for the player for such a simple act.

  • You could always do a check for is overlapping on the click/touch with your shape and react to that.

  • I don't get it. What is weird about having every sprite be the same resolution when you want everything to be placed in a grid on the screen?

    I didn't say that's weird.

    It's not about C2 being smart, like any computer software C2 does what it's told to do. In this case, you're telling it to do the wrong thing.

    What is wrong is having the collision polygons occupy the entire frame of the image. Those polygons are hotspots that are used to detect when the mouse is clicking the image, so if the hotspots are too big, then the click detection will be wrong.

    Having overlapping images is not the issue, it's having overlapping collision polygons.

    I've made two quick examples to show you the wrong and the right way to handle overlapping images. Both use identical, overlapping images.

    In the wrong example, I've set the collision polygons to be the full size of the image - 256x256.

    In the right example, I've set the collision polygons to fix the actual artwork in the image and not occupy the empty space around it.

    Download both and tell me which one better represents the idea you're trying to achieve.

  • BluePhaze

    Brilliant idea, but I'm not sure that I'm doing it right, for me that produces the same results. It's because the hitboxes are overlapping each other with alpha.

    I tried doing it so that it also checks for cursor is over object, but that produces the same result.

    I then tried creating a 1x1 sprite that is always where the cursor is, and then checking if the 1x1 sprite is overlapping, but this also produces the same result.

    What am I doing wrong here?

  • GeometriX

    I downloaded your projects, but I can't open them because steam refuse to update my version of construct 2 to the latest beta..

    I tried restarting steam and validating the files, but it won't update even when it's set to take beta updates. Are the latest updates not uploaded to steam?

  • I downloaded the free version of the beta just to try out your example, and I'm pleased to say that the collision polygon right.capx is what I'm trying to achieve, but I don't what you did to alter the collision polygons, I'll try google and see if I can't figure it out, thanks to you, I now know what to search for (I think)

  • I got it to work now, thank you very much! The problem was that I wasn't aware that you can change the collision polygons ;)

    Here is what I have now, it's much better:

    dropbox.com/s/u277vwvf2wtuoqm/Space%20Station%2013.capx

  • Bingo - that's what I was talking about :)

    Glad you've come right.

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