Wire up for hit-testing just like object tiles.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@986 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -274,6 +274,11 @@ public class CharacterSprite extends Sprite
|
||||
}
|
||||
}
|
||||
|
||||
public function hitTest (stageX :int, stageY :int) :Boolean
|
||||
{
|
||||
return _framesBitmap == null ? false : _framesBitmap.hitTest(stageX, stageY);
|
||||
}
|
||||
|
||||
/** The action to use when at rest. */
|
||||
protected var _restingAction :String = StandardActions.STANDING;
|
||||
|
||||
@@ -297,13 +302,6 @@ public class CharacterSprite extends Sprite
|
||||
/** The currently active set of bitmaps for this character. */
|
||||
protected var _framesBitmap :MultiFrameBitmap;
|
||||
|
||||
/** The offset from the upper-left of the total sprite bounds to the
|
||||
* upper-left of the image within those bounds. */
|
||||
protected var _ioff :Point = new Point();
|
||||
|
||||
/** The bounds of the current sprite image. */
|
||||
protected var _ibounds :Rectangle = new Rectangle();
|
||||
|
||||
/** The orientation of this sprite. */
|
||||
protected var _orient :int = DirectionCodes.NONE;
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ package com.threerings.cast {
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.Sprite;
|
||||
|
||||
import flash.geom.Point;
|
||||
|
||||
import flash.events.Event;
|
||||
|
||||
import com.threerings.media.Tickable;
|
||||
@@ -73,6 +75,22 @@ public class MultiFrameBitmap extends Sprite
|
||||
return _frames.length;
|
||||
}
|
||||
|
||||
public function hitTest (stageX :int, stageY :int) :Boolean
|
||||
{
|
||||
if (_curFrameIndex == -1) {
|
||||
return false;
|
||||
} else {
|
||||
var frame :Bitmap = getFrame(_curFrameIndex);
|
||||
if (frame.hitTestPoint(stageX, stageY, true)) {
|
||||
// Doesn't even hit the bounds...
|
||||
return false;
|
||||
}
|
||||
// Check the actual pixels...
|
||||
var pt :Point = frame.globalToLocal(new Point(stageX, stageY));
|
||||
return frame.bitmapData.hitTest(new Point(0, 0), 0, pt);
|
||||
}
|
||||
}
|
||||
|
||||
protected var _frames :Array;
|
||||
|
||||
protected var _bitmap :Bitmap;
|
||||
|
||||
Reference in New Issue
Block a user