# I need help with this expression.

Get help using Construct 2

### » Tue Nov 20, 2012 10:36 am

Here's the .capx: https://dl.dropbox.com/u/1910765/problem.capx

Basically, you destroy the blocks clicking on them, and when you do the blocks that are on top of the one you destroyed "fall" down on top of the others.

The blocks on the left work fine because they are all the same size, but the the other 2 piles if you destroy the bigger block, the ones on top won't fall down enough because in the events I only move them +40 pixels.

You can find that on the events where it says Blocks->Set position Self.Y+40

So what I need is to change that Self.Y+40 to some kind of expression that finds the correct distance between the blocks on top and the checkdummy object, so even when the blocks are larger, once you destroy them, the blocks on top will position themselves correctly.

The checkdummy object is the grey sprite that it always positions itself on top of the pile, so everytime you destroy a block, this will create a gap and the checkdummy will position itself there. I thought this could come in handy, but since I suck at math I have a really hard time with expressions, maybe you guys can think of something.

Also, I need to do this with that one expression preferably, I don't want to have a bunch of different events depending on the size of the block.

Of course if you know of a better way to do this let me know too. Thanks. Feel free to ask anything.
B
76
S
29
G
17
Posts: 256
Reputation: 15,275

### » Tue Nov 20, 2012 11:38 am

I can't open the project at this moment, but could Set position to checkdummy.y work?

Maybe because the blocks are different size, checkdummy.y-0.5*sprite.height or something like that?LittleStain2012-11-20 11:45:10
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Tue Nov 20, 2012 2:30 pm

I think a new rule for those posting projects to get assistance on: declare all custom plugins you have installed.
B
20
S
4
G
2
Posts: 124
Reputation: 2,482

### » Tue Nov 20, 2012 5:40 pm

Try again please, I forgot to delete a behavior. Sorry.
B
76
S
29
G
17
Posts: 256
Reputation: 15,275