Alternatives to Falling Blocks without Physic

Get help using Construct 2

Post » Sat Feb 16, 2013 7:09 am

Btw, a reference

B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Sat Feb 16, 2013 9:38 am

A couple of ideas...

Set some flag that says if anything is falling which is checked before you can start any more from starting to fall

I don't have the code with me, so from memory - when you touch an invader/gem it goes through the ones above and sets them to fall a set distance from their present y pos. I think the problem is that if , while falling, it is set to fall again. Some instance variable that says this this is where I am already falling to so add any further falling distance to this and this new (total) y position is where I will stop falling.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
59
S
30
G
34
Posts: 1,194
Reputation: 23,767

Post » Sat Feb 16, 2013 10:12 am

OK fired up the old laptop and went with option two.

https://dl.dropbox.com/u/143636437/invaders/index.html

capx updated.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
59
S
30
G
34
Posts: 1,194
Reputation: 23,767

Post » Sat Feb 16, 2013 11:15 am

I solved this for my WIP game by using easeTween, Array of UID's. It's a bit complicated and until I finish the game I'm a bit reluctant to share capx :)

When each instance is created I assign it to the corresponding Column ( I use floor(sprite.X / sprite.Width) to get 0-10 for 10 columns for example ) and store the UID's for each in a 2D array (GameBoard). When you remove an instance it's deleted from the array (set value to 0)

To drop them I just add them and drop them by using easeTween(relative) setting Target X to (GameBoard.Height - ColumnCount) * Sprite.Height ( (10 - 2 )*80) . Setting easeTween with an easeBounceOut makes them look like physics objects too.

When you remove a assets I call a function UpdatePositions which just run's through all the populated GameBoards UID's and counts how many blank spots are below. Repeat GameBoard.Height - Sprite.GameBoardY (repeats down 10-8) and then if Array's Spot is 0 add 1 to MoveAmount else do nothing.

Then at the end it just move the Sprite it was testing by MoveAmount * Sprite.Height using easeTween again.

Maybe if I get some time I can produce a stripped down capx to show.
B
24
S
11
G
5
Posts: 140
Reputation: 5,004

Post » Sun Feb 17, 2013 1:42 am

@RamPackWobble you only added some function when you click a block while is falling, it doesn't destroy.

Here comes an annoying issue, if you try to destroy a group of blocks, they won't fall. Also i used your codebase, it breaks the game when i tried to spawn another from above and it goes wrong position, it's overlapping to next 4 blocks down.

Are you thinking to use comparing 2 values Block.Y and Block.Height? i tried it, but i couldn't figure out.

http://dl.dropbox.com/u/76227787/wrongfallgroup.capx



@labithiotis Oh really? I have a question, when some blocks were destroyed (including destroyed single block and multiple blocks) and spawn another blocks from above then fall, would it work?
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Sun Feb 17, 2013 6:53 am

Anyways, i created a thread if you want help me, in return you get a reward

http://www.scirra.com/forum/topic63653.html

You can replace a workaround in event number 10, it shouldn't be collision checkJoannesalfa2013-02-17 06:54:36
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Post » Sun Feb 17, 2013 9:15 am

[QUOTE=Joannesalfa] @RamPackWobble you only added some function when you click a block while is falling, it doesn't destroy.

? Works here on a pc and ipad - could you try again and let me know what you are running on ? the aliens are smaller than the earlier version in a grid of about 18 X 12 with a FPS display in top left ?

The ideas of using a plug in sounds good - but I've never tried any extra plugins yet (still trying to learn my way around the basic program...)
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
59
S
30
G
34
Posts: 1,194
Reputation: 23,767

Post » Sun Feb 17, 2013 6:29 pm

[QUOTE=RamPackWobble] [QUOTE=Joannesalfa] @RamPackWobble you only added some function when you click a block while is falling, it doesn't destroy.

? Works here on a pc and ipad - could you try again and let me know what you are running on ? the aliens are smaller than the earlier version in a grid of about 18 X 12 with a FPS display in top left ?

The ideas of using a plug in sounds good - but I've never tried any extra plugins yet (still trying to learn my way around the basic program...)[/QUOTE]

@RamPackWobble

I'm sorry. I already tested it on my iPod touch 4 and it's working fine, the problem is when you destroy a group of blocks, they don't fall togheter anymore, i already posted a .capx for you.

I don't think plugin is neccesary, it would cost you a lot of time.Joannesalfa2013-02-17 18:30:32
B
96
S
25
G
20
Posts: 3,055
Reputation: 22,644

Previous

Return to How do I....?

Who is online

Users browsing this forum: Zebbi and 27 guests