In same x,y

For questions about using Classic.

Post » Mon Jan 14, 2008 11:28 pm

Is there a crafty function to use to check if there is an object at the exact same x and y as another? I am trying to make a system to automatically delete remnants in my system. I need to get it so that if I spawn more than 1 of an object, it deletes them. I was wondering if there is a crafty way or a function to check if there's an object in the EXACT same X,Y, and not just an object that may overlay. Thank you :)
B
2
S
1
G
5
Posts: 54
Reputation: 1,508

Post » Mon Jan 14, 2008 11:57 pm



(Now here's where I get a reply saying "No, no, I meant this" because the question was too ambiguous to decipher correctly.)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Mon Jan 14, 2008 11:59 pm

Yeah, sorry, I should have specified it better. What I really meant was the same exact object placed on top of itself. The problem with using that logic for the same object is that it won't be able to tell the difference between the two. Thanks
B
2
S
1
G
5
Posts: 54
Reputation: 1,508

Post » Tue Jan 15, 2008 12:00 pm

Objects use floating point values for their coordinates in Construct. Due to how floating point values work on processors the objects may appear to be at the same place, but their X and Y coordinates will differ ever so slightly. You would probably want to round the coordinates and just test to the nearest pixel. You would do it like this, using compare values:

round(Sprite.X) equal to round(Sprite2.X)
round(Sprite.Y) equal to round(Sprite2.Y)

If you want to test multiple 'Sprite's with this method, put a 'For each Sprite' condition at the top.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests