//This call: collision_cratesVSmap(crateStormGroup, collisionMap); //is equivalent in affect to this call: FlxG.collide(crateStormGroup, collisionMap, crateOnWallAction); private function collision_cratesVSmap(objectOrGroup1:FlxBasic, objectOrGroup2:FlxBasic):void { FlxG.overlap(objectOrGroup1, objectOrGroup2, crateOnWallAction, FlxObject.separate); } private function crateOnWallAction(b1:FlxBasic, b2:FlxBasic):void { //get the object that is NOT the wall, but our sprite. var b:FlxSprite; if (b1 is FlxSprite) { b = b1 as FlxSprite; } else if (b2 is FlxSprite) { b = b2 as FlxSprite; } if (b1 is Sprite && b2 is Sprite) { throw new Error("both sprites"); } b.acceleration.x = 0 - b.acceleration.x; b.acceleration.y = 0 - b.acceleration.y; }
Monday, December 17, 2012
Flixel Collision Notes
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment