C2 Math question

Get help using Construct 2

Post » Sat Feb 18, 2012 6:20 pm

Well it has worked perfectly for me in the past. Also, it is in the same wrong relative position regardless of the layer rotation.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Sat Feb 18, 2012 6:47 pm

Here's a different way to look at it.
http://dl.dropbox.com/u/666516/randangleimagepoint.capx

As to the layer angle, remember the rotation is counter clockwise, since in essence you are rotating the view.
Image ImageImage
B
169
S
50
G
169
Posts: 8,289
Reputation: 108,222

Post » Sat Feb 18, 2012 7:35 pm

@newt
That looks great! although why do you use numbers 4 and 16 instead of expressions of the size of the box? Basically to adapt this for my own purposes, I need to know how to adjust these constants.sqiddster2012-02-18 19:36:29
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Sat Feb 18, 2012 7:43 pm

It just divides the rectangle up into the size of the second sprite.
Looks a little better imho, and its easier to get around the issue with hotspots on the second object.
So rectangle width divided by the second objects width/2 *the second objects width.
Image ImageImage
B
169
S
50
G
169
Posts: 8,289
Reputation: 108,222

Post » Sat Feb 18, 2012 8:03 pm

By using a random angle and random distance the point ends up in a circle, the corners are never selected.

Here is how to have the point random out of the whole area.
http://dl.dropbox.com/u/5426011/examples%209/randpointonrect.capx
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Sat Feb 18, 2012 8:04 pm

OK, thanks, @newt.
The only problem is, the object within the rectangle has an altering width for me, and I suspect that this is what is stuffing it up.
What can I do if I want to consider the second object as a point entity?
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Sat Feb 18, 2012 8:05 pm

randomAngledArea.capx
What I wrote earlier works fine for me...
Last edited by Yann on Sun Sep 14, 2014 9:35 pm, edited 1 time in total.
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

Post » Sat Feb 18, 2012 8:05 pm

oh, @r0j0hound, I missed that in Newt's example.
All right then, I'll go with yours, especially as it seems to allow an arbitrary width for the second object.

Many thanks all.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Post » Sat Feb 18, 2012 8:09 pm

Oh, shoot, @R0J0hound's won't work for me, I want to specify a position for the object to lerp to, not just make it appear there :(
Suppose I'll just use Yann's.
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,679

Previous

Return to How do I....?

Who is online

Users browsing this forum: Fenix18, Lancifer and 54 guests