Event condition- there is NOT a box at X,Y

For questions about using Classic.

Post » Fri Sep 04, 2009 6:53 pm

So i need a condition which will determine if there is not a box at X,Y.
To determine if there is one, i used

for each box
box.x=x
box.y=y

but if you do an else, it will check the first box to see if it is at x,y, then if the first box is not there it will go to the else. I want it to check ALL the instances, and if none of them are at x,y, then it determines there is no box at x,y.

make sense?
B
1
G
3
Posts: 5
Reputation: 835

Post » Fri Sep 04, 2009 7:20 pm

right click any condition, invert condition. :mrgreen:
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Fri Sep 04, 2009 7:41 pm

yes, but what do I invert?
obviously not "for each box".
If i invert the box.x=x, then im just checking if theres a box at y and not at x.
if i invert the box.y=y, then im jest checking if theres a box at x and not y.
if i invert both box.x=x and box.y=y, then im checking if theres a box somewhere else.
but theres fifteen boxes in the game- of course theres one somewhere else. i want to know if there is NOT one there.
B
1
G
3
Posts: 5
Reputation: 835

Post » Fri Sep 04, 2009 7:47 pm

private variable ('anybox')=0
for each box
----if box at x
--------if box at y -----anybox =1

if anybox = 1, that means there is at least one box there
else, no boxes are there
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Fri Sep 04, 2009 8:06 pm

But what if the box moves? The variable still equals 1, but theres no box there.
B
1
G
3
Posts: 5
Reputation: 835

Post » Fri Sep 04, 2009 8:20 pm

perhaps a bit more information would help. i am making a game where the player picks up and moves boxes. Currently you can pick up the bottom box in a stack. That should not be. You should only be able to pick up the top box. So, i used the condition described at the begining to find out if a box was under another box. If so, it gets stuck. THe problem is, once the player moves the box above, the box below still thinks it's stuck.
B
1
G
3
Posts: 5
Reputation: 835

Post » Fri Sep 04, 2009 8:39 pm

if you set it to 0 before you do the for each condition each time it will be 0 if its not there, and 1 if it is,
regardless of what the condition was in the last tick

also, for what you described, the "is overlapping at offset" condition might be more appropriate
and would be much simpler, though you'll have to use the family trick

for instance
box is overlapping "boxfamily" at offset x=0,y=-5
make box immovable
you have to do this with a family,
as in : Box is overlapping Box
it will think you want both boxes to be immovable
so by separating the condition with a family, it understands the boxes you are overlapping
are not meant to be picked for the actions

example:
drag and drop boxes
http://dl.getdropbox.com/u/1013446/boxthing.cap
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Fri Sep 04, 2009 11:08 pm

THANK YOU! Overlap at offset makes EVERYTHING in my life better. It made doing this a 30 second affair, not the 5 hour one it was, and it will make the other things that i need to fix eaiser.
You are a lifesaver.
B
1
G
3
Posts: 5
Reputation: 835


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests