Skip to content

Commit

Permalink
tilemap collision resolution should preserve quadtree A-B list parity…
Browse files Browse the repository at this point in the history
… and parameter order now
  • Loading branch information
AdamAtomic committed Apr 25, 2011
1 parent d1a8616 commit 864f775
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
4 changes: 2 additions & 2 deletions org/flixel/FlxObject.as
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
15 changes: 11 additions & 4 deletions org/flixel/FlxParticle.as
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ 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.
Expand All @@ -28,6 +35,7 @@ package org.flixel
{
super();
lifespan = 0;
friction = 500;
}

/**
Expand All @@ -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;
Expand All @@ -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.
Expand Down
14 changes: 10 additions & 4 deletions org/flixel/FlxTilemap.as
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 864f775

Please sign in to comment.