Permalink
Browse files

tilemap collision resolution should preserve quadtree A-B list parity…

… and parameter order now
  • Loading branch information...
1 parent d1a8616 commit 864f7753c1395d30964b1bd2f64283ae7ef28a9c @AdamAtomic committed Apr 25, 2011
Showing with 23 additions and 10 deletions.
  1. +2 −2 org/flixel/FlxObject.as
  2. +11 −4 org/flixel/FlxParticle.as
  3. +10 −4 org/flixel/FlxTilemap.as
View
@@ -906,7 +906,7 @@ package org.flixel
if(Object1 is FlxTilemap)
return (Object1 as FlxTilemap).overlapsWithCallback(Object2,separateX);
if(Object2 is FlxTilemap)
- return (Object2 as FlxTilemap).overlapsWithCallback(Object1,separateX);
+ return (Object2 as FlxTilemap).overlapsWithCallback(Object1,separateX,true);
//First, get the two object deltas
var overlap:Number = 0;
@@ -1005,7 +1005,7 @@ package org.flixel
if(Object1 is FlxTilemap)
return (Object1 as FlxTilemap).overlapsWithCallback(Object2,separateY);
if(Object2 is FlxTilemap)
- return (Object2 as FlxTilemap).overlapsWithCallback(Object1,separateY);
+ return (Object2 as FlxTilemap).overlapsWithCallback(Object1,separateY,true);
//First, get the two object deltas
var overlap:Number = 0;
View
@@ -21,13 +21,21 @@ package org.flixel
public var lifespan:Number;
/**
+ * Determines how quickly the particles come to rest on the ground.
+ * Only used if the particle has gravity-like acceleration applied.
+ * @default 500
+ */
+ public var friction:Number;
+
+ /**
* Instantiate a new particle. Like <code>FlxSprite</code>, all meaningful creation
* happens during <code>loadGraphic()</code> or <code>makeGraphic()</code> or whatever.
*/
public function FlxParticle()
{
super();
lifespan = 0;
+ friction = 500;
}
/**
@@ -47,17 +55,17 @@ package org.flixel
if(touching)
{
if(angularVelocity != 0)
- angularVelocity = -angularVelocity * elasticity;
+ angularVelocity = -angularVelocity;
}
if(acceleration.y > 0) //special behavior for particles with gravity
{
if(touching & FLOOR)
{
- drag.x = 200;
+ drag.x = friction;
if(!(wasTouching & FLOOR))
{
- if(velocity.y < -elasticity*100)
+ if(velocity.y < -elasticity*10)
{
if(angularVelocity != 0)
angularVelocity *= -elasticity;
@@ -75,7 +83,6 @@ package org.flixel
return;
}
-
/**
* Triggered whenever this object is launched by a <code>FlxEmitter</code>.
* You can override this to add custom behavior like a sound or AI or something.
View
@@ -803,12 +803,13 @@ package org.flixel
* and calls the specified callback function (if there is one).
* Also calls the tile's registered callback if the filter matches.
*
- * @param Object The <code>FlxObject</code> you are checking for overlaps against.
- * @param Callback An optional function that takes the form "myCallback(Object1:FlxObject,Object2:FlxObject)", where one object is the object passed in in the first parameter, and the other is the relevant FlxTile from _tileObjects.
+ * @param Object The <code>FlxObject</code> you are checking for overlaps against.
+ * @param Callback An optional function that takes the form "myCallback(Object1:FlxObject,Object2:FlxObject)", where Object1 is a FlxTile object, and Object2 is the object passed in in the first parameter of this method.
+ * @param FlipCallbackParams Used to preserve A-B list ordering from FlxObject.separate() - returns the FlxTile object as the second parameter instead.
*
* @return Whether there were overlaps, or if a callback was specified, whatever the return value of the callback was.
*/
- public function overlapsWithCallback(Object:FlxObject,Callback:Function=null):Boolean
+ public function overlapsWithCallback(Object:FlxObject,Callback:Function=null,FlipCallbackParams:Boolean=false):Boolean
{
var results:Boolean = false;
@@ -850,7 +851,12 @@ package org.flixel
tile.last.x = tile.x - deltaX;
tile.last.y = tile.y - deltaY;
if(Callback != null)
- overlapFound = Callback(Object,tile);
+ {
+ if(FlipCallbackParams)
+ overlapFound = Callback(Object,tile);
+ else
+ Callback(tile,Object);
+ }
else
overlapFound = (Object.x + Object.width > tile.x) && (Object.x < tile.x + tile.width) && (Object.y + Object.height > tile.y) && (Object.y < tile.y + tile.height);
if(overlapFound)

0 comments on commit 864f775

Please sign in to comment.