How do I create object in hitbox that isn't square?

Get help using Construct 2

Post » Tue Aug 01, 2017 4:56 pm

I have a large diamond shape that doesn't take up the whole screen, it does change size though.
The diamond and image size is 2 parts width and 1 part height.
100 width, 50 height
1000 width , 500 height... etc

What I currently have isn't using a hitbox. It works, but is a mess.

Is it possible to spawn objects in a hitbox that isn't square?

I suppose I could add hidden objects where I don't want it to spawn, but I usually try to avoid hidden objects.
Last edited by Unconnected on Wed Sep 13, 2017 1:10 am, edited 1 time in total.
B
65
S
37
G
13
Posts: 240
Reputation: 12,703

Post » Tue Aug 01, 2017 8:05 pm

Hello,

If you dont want to post a .capx you send me a PM with it.

Im not really sure about what you want but i thinks i can help. (Im french you can try to explain just what you want)

Best Regard,
Casimir
B
11
S
3
Posts: 40
Reputation: 815

Post » Tue Aug 01, 2017 10:13 pm

Break up the shape in triangles, using imagepoints.

First choose a random triangle.
Then choose a random point like this.

https://www.dropbox.com/s/at7rdg1w357mu ... .capx?dl=0
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Aug 02, 2017 5:11 am

It seems exactly what I need, but It is confusing a small bit to me. I will have to dissect it.
I understand how to use it as it is, but would like to know a small bit more.

Why are you setting r1 and r2 to random(1) instead of just setting it to 1?
How is it picking a random point? The only random I see is random(1).
I never used or seen a random without two limits. Random(0, 10) etc.

Can you give a simple explanation for the rX and rY formula?
I do notice that one controls the X and one controls the Y.
B
65
S
37
G
13
Posts: 240
Reputation: 12,703

Post » Wed Aug 02, 2017 8:26 am

random(1) generates a number between 0 and 0.9999999999999999999
random(5) generates a number between 0 and 4.9999999999999999999

It needs 2 randoms, else the distribution will be more dense around the centre. (barycentre)

Explanation:
https://adamswaab.wordpress.com/2009/12 ... ordinates/
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Aug 02, 2017 12:43 pm

Thanks, helpful as always. :D

:P
B
65
S
37
G
13
Posts: 240
Reputation: 12,703


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, ignaciosimo and 49 guests