Sign in to follow this  
Tubilok

Blocks collapse

Recommended Posts

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/

Share this post


Link to post
Share on other sites

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".

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.