Tubilok Posted August 19, 2014 Share Posted August 19, 2014 Can someone tell me how to avoid the blocks collapse? http://jsfiddle.net/23y28hwp/ Link to comment Share on other sites More sharing options...
lewster32 Posted August 19, 2014 Share Posted August 19, 2014 This is a limitation of the Physics engine, which isn't designed for this kind of heavy multi-collision simulation. See this post for more: http://www.html5gamedevs.com/topic/7810-how-to-increase-rigidity-of-arcade-sprite-bodies/ Link to comment Share on other sites More sharing options...
Tubilok Posted August 19, 2014 Author Share Posted August 19, 2014 So if I use P2 physics I will not have this problem? Link to comment Share on other sites More sharing options...
lewster32 Posted August 19, 2014 Share Posted August 19, 2014 I'd suggest not using physics at all - use tweens. Everything is meant to be aligned to a grid and physics systems just aren't good at that kinda thing. Here's a modified version of your fiddle with some cheap hacks to stop the stacks collapsing but they're just that; cheap hacks. I wouldn't use these for a proper game: http://jsfiddle.net/lewster32/23y28hwp/2/ Link to comment Share on other sites More sharing options...
wayfinder Posted August 19, 2014 Share Posted August 19, 2014 With P2, you will have different problems lewster32 1 Link to comment Share on other sites More sharing options...
ZoomBox Posted August 19, 2014 Share Posted August 19, 2014 You should seriously use tweens:-It's way cheaper in term of performances-It's way more accurate (since you control everything) A second solution would be to create your own tiny physic thing: Make everything have an increasing Y position until they reach something else's Y position.That's the best alternative if you want to keep it "physic". d13 1 Link to comment Share on other sites More sharing options...
Tubilok Posted August 19, 2014 Author Share Posted August 19, 2014 Thank you very much everyone for your tips. It seems that the best solution is to use tweens. But do not know how I can get the same result with tweens, someone can guide me a little? Link to comment Share on other sites More sharing options...
Nepoxx Posted August 19, 2014 Share Posted August 19, 2014 You could also take a look at http://box2d-js.sourceforge.net/index2.html Link to comment Share on other sites More sharing options...
lewster32 Posted August 19, 2014 Share Posted August 19, 2014 I strongly urge you avoid using any physics systems for this, since I doubt any will be up to the job and will at best be hugely wasteful, perform poorly and introduce positioning inaccuracies which are absolutely not what you want in a grid-based game. Take a look at this example - particularly the 'dropGems' function: http://examples.phaser.io/_site/view_full.html?d=games&f=gemmatch.js&t=gemmatch Link to comment Share on other sites More sharing options...
Nepoxx Posted August 19, 2014 Share Posted August 19, 2014 I agree with you lewster32, however it is not said (or did I misread?) that this is a grid-based game (if it is, please do not use a physics system). Link to comment Share on other sites More sharing options...
lewster32 Posted August 19, 2014 Share Posted August 19, 2014 It seems to me that if all the boxes are the same size, are spawned on an x-axis grid and aren't meant to intersect, then it's likely to be a grid-based game. I could be totally wrong in my assumptions of course! If there's a need to actually have a stack of physics objects like that, then we really need more info about what it is Tubilok is trying to achieve. Nepoxx 1 Link to comment Share on other sites More sharing options...
ZoomBox Posted August 19, 2014 Share Posted August 19, 2014 In the gemmatch example, just change the easing equation to a Bounce.Out to make a very nice physic-alike effect.BUT, don't start from this code.It's a nice example to show possibilities but it's a pain in the a** to start from. Link to comment Share on other sites More sharing options...
Tubilok Posted August 19, 2014 Author Share Posted August 19, 2014 I'll take a look at the gemmatch example, although it seems rather complicated. FYI, I want to do something like this: I hoped it was something simple with Phaser but it seems I was wrong. Link to comment Share on other sites More sharing options...
Nepoxx Posted August 19, 2014 Share Posted August 19, 2014 I'll take a look at the gemmatch example, although it seems rather complicated. FYI, I want to do something like this: I hoped it was something simple with Phaser but it seems I was wrong. You are wrong in thinking that you are wrong. You are making a grid based game. When you spawn a box, you simply make a tween that brings it to the slot above the topmost box already in the column (my explanation might be vague). You do not need physics for the box part at all. Link to comment Share on other sites More sharing options...
Tubilok Posted August 20, 2014 Author Share Posted August 20, 2014 I finally got the desired result using tweens. Thank you all lewster32 1 Link to comment Share on other sites More sharing options...
Recommended Posts