same object comparing

For questions about using Classic.

Post » Sat Jul 11, 2009 10:51 am

What I want to do is compare the distance between 2 instances of Sprite, and then move them away if they are too close. But I don't know how I can do that, I was thinking I could use "compare" and then use the distance formula but I don't see how it would know which 2 instances to choose from.
Would line of sight behavour be a good solution: checking if SpriteA has "on LOS to SpirteA"?
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

Post » Sat Jul 11, 2009 11:11 am

Wouldn't overlapping at offset work?
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Sat Jul 11, 2009 11:15 am

You could use the family picking trick for that, I think.

Put all Sprites into Foo Family. Then do like so:

[code:ibzrmbk7]
+ Sprite distance(Sprite.X, Sprite.Y, Foo.X, Foo.Y) is less than whatever
-> Move Sprite away from Foo
[/code:ibzrmbk7]


[quote="newt":ibzrmbk7]Wouldn't overlapping at offset work?[/quote:ibzrmbk7]

How so?
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Jul 11, 2009 11:22 am

oh newt, cheers for the idea. I tried giving the Sprite a massive detector image that surrounds the object and made it a container, then when that detector overlaps another Sprite it moves it away! yay

edit: oops didn't see your post deadeye, maybe I should try that method too
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests