Jump to content

Falling bricks


darcys22
 Share

Recommended Posts

I am creating a game where a player can click on the screen to create bricks. I am trying to get these bricks to stack on top of this other and never overlap.

 

I currently don't have any collision function being called when they collide (arcade)

 

The defaults makes the bricks spring a little when they collide, they compress with weight, and after a few are stacked they fall through each other (even through my floor, which is an immovable sprite).

 

Could someone point me in the right direction so I can tweak the arcade physics? It would be exactly how the pieces in tetris interact with each other.

 

Thanks

Link to comment
Share on other sites

This isn't practical with the physics engine, you need to approach this differently for the kind of game you're making, using grids and either tweens or some manual per-frame movement routine. Similar posts with more info can be found here:

Link to comment
Share on other sites

Okay so I made the bricks fall using a tween, then when they overlap with another brick (Overlap without physics tutorial) I stop the tween.

 

However they are also draggable so when one of the bricks underneith is moved I would like them to continue falling.

 

Is there an easy way of doing this?

Link to comment
Share on other sites

When you drag the brick, does it remove it from the playing area temporarily while it's held, or can things collide with it during the dragging? If so, then this will be rather difficult to get working.

 

The way these things are typically done in Tetris, Candy Crush and so on is via an underlying data structure that represents the grid. Each 'cell' either has something in it, or not, and the positions of things on this grid influence the smoothed tweens of the visual objects. See this example:

 

http://examples.phaser.io/_site/view_full.html?d=games&f=gemmatch.js&t=gemmatch

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...