Drag-and-drop-and-snap

Get help using Construct 2

Post » Tue Sep 30, 2014 9:15 am

The event 11 trick was so the pinned connector sprite's positions would be updated before moving.
The reason for this is the game flow is like the following and we have to wait for the next frame for pin to run again.

behaviors -> event sheet -> draw -> repeat.

Wait 0 or with a very low time can be ready by the end of the event sheet, so wait with a higher value or "wait signal" worked. Although I agree it's not a very clean solution.

The clean solution would be to do pin in events so I can update the pinned objects whenever I need.
https://dl.dropboxusercontent.com/u/542 ... zzle2.capx

But sometimes it's easier to just make do with exiting behaviors.
B
94
S
33
G
118
Posts: 5,396
Reputation: 75,853

Post » Tue Sep 30, 2014 10:11 am

Thanks very much. I've adapted your design to my objects (well 1 so far) but the normal calculation will need to be hard coded for each object? As I have a number of objects. Did you just choose the angle (x1, y1, x2, t2) values by any special technique?
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Tue Sep 30, 2014 11:15 am

The normal is just the angle perpendicular to the edge facing out. For instance the slope (rise/run or change in y divided by the change in x) or the right edge is 2/1 and the norm slope is 1/-2. The calculation of angle from slope is angle(0,0,run,rise). Another way is to guess the angles, test and re adjust
B
94
S
33
G
118
Posts: 5,396
Reputation: 75,853

Post » Tue Sep 30, 2014 3:14 pm

R0J0hound at rescue again I was looking for something like this thanks R0J0hound
B
257
S
43
G
15
Posts: 1,992
Reputation: 41,535

Post » Tue Sep 30, 2014 11:12 pm

@R0J0hound I see a new behaviour in your future... align-and-snap. With an automatic normal generator based on polygon edge :)
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Wed Oct 01, 2014 4:16 am

The problem with making a plugin is the need of a way to specify which edges are snappable. Unless all edges should be. So defining the edges that snap would be the nearly the same, you'd still need to specify the normal.
B
94
S
33
G
118
Posts: 5,396
Reputation: 75,853

Post » Wed Oct 01, 2014 6:10 am

@R0J0hound,

Wish I could steal your brain, you never cease to amaze.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,728

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests