home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mobiclic 161
/
MOBICLIC161.ISO
/
pc
/
DATA
/
DSS161
/
DSS161_00
/
DSS161_00.swf
/
scripts
/
dss161
/
engineaddons
/
gamesprotos
/
CollisionTest.as
< prev
next >
Wrap
Text File
|
2014-01-15
|
4KB
|
140 lines
package dss161.engineaddons.gamesprotos
{
import dss161.engineaddons.gamesprotos.actors.actorClip.ActorClip;
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.geom.Point;
public class CollisionTest
{
private var actor:ActorClip;
private var _clip:MovieClip;
protected var hitTestDistanceParams:Object;
public function CollisionTest(param1:ActorClip)
{
this.hitTestDistanceParams = {"distanceMini":100000};
super();
this.actor = param1;
this._clip = param1.clip;
}
public function withActor(param1:Actor) : Boolean
{
return this.hitTestObjects([param1]) != null;
}
public function withDisplayObject(param1:DisplayObject) : void
{
}
public function withCoord(param1:Number, param2:Number, param3:* = null) : void
{
}
public function withPoint(param1:Point, param2:* = null) : void
{
}
public function getNearestClip(param1:Array) : *
{
var _loc8_:Point = null;
var _loc2_:Number = -1;
var _loc3_:Number = 0;
var _loc4_:* = null;
var _loc5_:Point = this.actor.getLocPoint(this._clip);
var _loc6_:Point = new Point(0,0);
var _loc7_:int = 0;
while(_loc7_ < param1.length)
{
_loc8_ = new Point(param1[_loc7_].x,param1[_loc7_].y);
_loc5_ = this.actor.getPos();
_loc6_ = param1[_loc7_].parent.localToGlobal(_loc8_);
_loc3_ = Point.distance(_loc5_,_loc6_);
if(_loc3_ <= this.hitTestDistanceParams.distanceMini && (_loc2_ < 0 || _loc3_ < _loc2_))
{
_loc2_ = _loc3_;
_loc4_ = param1[_loc7_];
}
_loc7_++;
}
return _loc4_;
}
protected function hitTestObjects(param1:Array) : *
{
var _loc2_:DisplayObject = null;
var _loc3_:DisplayObject = null;
var _loc4_:int = 0;
var _loc5_:int = 0;
var _loc6_:int = 0;
var _loc7_:Array = [];
if(this.actor.hitZones.length > 0)
{
_loc4_ = 0;
while(_loc4_ < this.actor.hitZones.length)
{
_loc2_ = this.actor.hitZones[_loc4_];
_loc5_ = 0;
while(_loc5_ < param1.length)
{
if(param1[_loc5_].hitZones.length > 0)
{
_loc6_ = 0;
while(_loc6_ < param1[_loc5_].hitZones.length)
{
_loc3_ = param1[_loc5_].hitZones[_loc6_];
if(_loc2_.hitTestObject(_loc3_))
{
_loc7_.push(param1[_loc5_]);
}
_loc6_++;
}
}
else if(_loc2_.hitTestObject(param1[_loc5_].clip))
{
_loc7_.push(param1[_loc5_]);
}
_loc5_++;
}
_loc4_++;
}
return this.getNearestClip(_loc7_);
}
_loc5_ = 0;
while(_loc5_ < param1.length)
{
if(param1[_loc5_].hitZones.length > 0)
{
_loc6_ = 0;
while(_loc6_ < param1[_loc5_].hitZones.length)
{
_loc3_ = param1[_loc5_].hitZones[_loc6_];
if(this._clip.hitTestObject(_loc3_))
{
_loc7_.push(param1[_loc5_]);
}
_loc6_++;
}
}
else if(this._clip.hitTestObject(param1[_loc5_].clip))
{
_loc7_.push(param1[_loc5_]);
}
_loc5_++;
}
return this.getNearestClip(_loc7_);
}
public function destroy() : void
{
this.actor = null;
this._clip = null;
}
}
}