Jump to content

Collision callbacks done - getting closer to release status


rich
 Share

Recommended Posts

I've just pushed a brand new build (with re-generated docs) that includes all of the new collision handling.

 

You can now create collision groups, assign sprites to them and perform body vs. body collision or body vs. group collision with callbacks for any unique body/group as needed.

 

It's a little more work to set-up than in 1.1, but with great power comes great responsibility and all that.

 

You can now also pass in a physics configuration object to the game constructor (or game config) and loads of other updates.

 

I still want to get some of the helper functions from ArcadePhysics ported over like moveToPointer, but on the whole this is getting very close to release status.

 

I'm probably going to leave Springs and Constraints for the next release after 1.2. Maybe :)

 

Also as this is such a dramatic change from 1.1 I'm toying with the idea of re-numbering it to Phaser v2 just so there's absolutely no confusion between a small incremental change. So much of the API has changed I think that might be a wise plan.

Link to comment
Share on other sites

I suggest you start using the semver notation (http://semver.org/) and 2.0 would be a good start for it.

This will give you a structured and consistent way of releasing new stuff and great support for package managers like bower which let you auto-update to, say, new patch versions, without worrying about compatibility.

This will also be a great help for your users, with basically no overhead on your side.

Link to comment
Share on other sites

Nice update!

 

Noticed some strange behavior with the collision groups. This can all be seen in the contact2 wip example.

 

With both the build from the build folder or from latest commit:

  • The gotBox function gets called twice for each collision

 

When built after latest commit:

  • Collision groups break(run contact2 to see the weird behavior) when game.physics.setBoundsToWorld or game.world.setBounds is used

 

If you are aware of these, just ignore this post.  :lol:

Link to comment
Share on other sites

I sorted out quite a bit last night, and even made a new labs demo :) Collision callbacks are pretty much working, just need to refine them a little more and I'm happy they are done. Tomorrow I've got a day to focus on this, porting the last of the ArcadePhysics classes over, and I may see about Springs and Constraints - although I'm still tempted to keep those for a 2.1 release, just because there's enough new stuff here as it is.

 

I'm also tempted to sort of put ArcadePhysics back in, but as a really light-weight AABB + intersects only system. So no separation, no "physics" (i.e. you can't set velocity or whatever), it would just purely be for those few games where a plain AABB system is enough. Still thinking it over anyway.

 

You can now configure the physics world from the game configuration object too, which is quite neat :) So you can pick an alternative broadphase system or set solver defaults.

Link to comment
Share on other sites

Played around with the new labs demo for way longer than I should have. 

 

Just tried the contact2 example again and it still looks like collision callbacks are called twice? Or is it just me?

 

Also, can you please point me in the right direction for the following:

  1. How do I do a callback when a collision ends?
  2. Is it possible to have 2 bodies collide, but only 1 body is effected by the collision? Example: Swinging ball on chain hits a player, player is bumped away, ball continues swinging as normal. Or a moving platform/elevator that hit a player? 
  3. How would I do overlaps with a callback?
  4. "One sided" platforms. Example: Player you can jump from bottom and not collide, but can walk on this platform.

 

Thanks!

Link to comment
Share on other sites

I'm also tempted to sort of put ArcadePhysics back in, but as a really light-weight AABB + intersects only system. So no separation, no "physics" (i.e. you can't set velocity or whatever), it would just purely be for those few games where a plain AABB system is enough. Still thinking it over anyway.

 

 

 

That is a great Idea.. - not only would it make for easier access, if you just want to do a simple game.

 

It would make it possible to port old games and take advantage of new features (tiniting, tilemaps... etc) without having to reinvent the whole game logic.

Link to comment
Share on other sites

It would be a bit dangerous if people assume this though - in order for old games to still work I would have to re-implement the entire old Body system + stacks of functions in ArcadePhysics (and all the issues it previously had too). I'll think it over.

Link to comment
Share on other sites

not sure to guarantee upward compatibility is really a good thing... It will complicate a lot the framework imho and make it very difficult to maintain

 

Why simply not keep old games under 1.1 versions ?

And choose with V2 wheter to use or not only AABB or a more complex physics engine for new games from now on.

 

But it's only my opinion ...

Link to comment
Share on other sites

Played around with the new labs demo for way longer than I should have. 

 

Just tried the contact2 example again and it still looks like collision callbacks are called twice? Or is it just me?

 

Also, can you please point me in the right direction for the following:

  1. How do I do a callback when a collision ends?
  2. Is it possible to have 2 bodies collide, but only 1 body is effected by the collision? Example: Swinging ball on chain hits a player, player is bumped away, ball continues swinging as normal. Or a moving platform/elevator that hit a player? 
  3. How would I do overlaps with a callback?
  4. "One sided" platforms. Example: Player you can jump from bottom and not collide, but can walk on this platform.

 

Thanks!

@lonan:  any luck with those questions?   i have the very same questions..  i can't even get a collision callback to work.. the docs say it sends 4 parameters..  

This body, the body that impacted, the Shape in this body and the shape in the impacting body.

 

but how to i use these in my callback function? i can do something like this:

 

player.body.createGroupCallback(starsCG, collectStars, this);        function collectStars(player,star) {            star.removeFromWorld();        }
 
but not this...  
star.body.moveUp(400);  
 
(instead of the removefromworld stuff)  because there is no body that can move up   :(
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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