How do I click through transparency?

Get help using Construct 2

Post » Sun Feb 10, 2013 7:53 pm

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?
B
4
Posts: 8
Reputation: 391

Post » Sun Feb 10, 2013 8:44 pm

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
B
20
S
5
G
8
Posts: 325
Reputation: 6,473

Post » Sun Feb 10, 2013 8:45 pm

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:
https://www.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! Dohman2013-02-11 09:25:40
B
4
Posts: 8
Reputation: 391

Post » Sun Feb 10, 2013 8:54 pm

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.GeometriX2013-02-10 20:56:47
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Mon Feb 11, 2013 6:54 am

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.
B
4
Posts: 8
Reputation: 391

Post » Mon Feb 11, 2013 6:59 am

You could always do a check for is overlapping on the click/touch with your shape and react to that.
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,418

Post » Mon Feb 11, 2013 8:28 am

[QUOTE=Dohman] 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?[/QUOTE]
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.
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Mon Feb 11, 2013 8:36 am

@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?Dohman2013-02-11 08:41:45
B
4
Posts: 8
Reputation: 391

Post » Mon Feb 11, 2013 8:41 am

@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?
B
4
Posts: 8
Reputation: 391

Post » Mon Feb 11, 2013 8:59 am

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)Dohman2013-02-11 08:59:41
B
4
Posts: 8
Reputation: 391

Next

Return to How do I....?

Who is online

Users browsing this forum: jobel, Timedoor Indones, Yahoo [Bot] and 21 guests