Some optimizations and cleanup, since sprites are already sorted by
render order in our internal list. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3733 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -81,14 +81,14 @@ public class SpriteManager extends AbstractMediaManager
|
|||||||
* and sprites with bounds that contain the supplied point are further
|
* and sprites with bounds that contain the supplied point are further
|
||||||
* checked for a non-transparent at the specified location.
|
* checked for a non-transparent at the specified location.
|
||||||
*
|
*
|
||||||
* @param list the list to fill with any intersecting sprites.
|
* @param list the list to fill with any intersecting sprites, the
|
||||||
|
* sprites with the highest render order provided first.
|
||||||
* @param x the x (screen) coordinate to be checked.
|
* @param x the x (screen) coordinate to be checked.
|
||||||
* @param y the y (screen) coordinate to be checked.
|
* @param y the y (screen) coordinate to be checked.
|
||||||
*/
|
*/
|
||||||
public void getHitSprites (List list, int x, int y)
|
public void getHitSprites (List list, int x, int y)
|
||||||
{
|
{
|
||||||
int size = _media.size();
|
for (int ii = _media.size() - 1; ii >= 0; ii--) {
|
||||||
for (int ii = 0; ii < size; ii++) {
|
|
||||||
Sprite sprite = (Sprite)_media.get(ii);
|
Sprite sprite = (Sprite)_media.get(ii);
|
||||||
if (sprite.hitTest(x, y)) {
|
if (sprite.hitTest(x, y)) {
|
||||||
list.add(sprite);
|
list.add(sprite);
|
||||||
@@ -106,18 +106,14 @@ public class SpriteManager extends AbstractMediaManager
|
|||||||
*/
|
*/
|
||||||
public Sprite getHighestHitSprite (int x, int y)
|
public Sprite getHighestHitSprite (int x, int y)
|
||||||
{
|
{
|
||||||
int size = _media.size(),
|
// since they're stored in lowest -> highest order..
|
||||||
highestLayer = Integer.MIN_VALUE;
|
for (int ii = _media.size() - 1; ii >= 0; ii--) {
|
||||||
Sprite highestSprite = null;
|
|
||||||
for (int ii = 0; ii < size; ii++) {
|
|
||||||
Sprite sprite = (Sprite)_media.get(ii);
|
Sprite sprite = (Sprite)_media.get(ii);
|
||||||
if (sprite.hitTest(x, y) &&
|
if (sprite.hitTest(x, y)) {
|
||||||
sprite.getRenderOrder() > highestLayer) {
|
return sprite;
|
||||||
highestSprite = sprite;
|
|
||||||
highestLayer = sprite.getRenderOrder();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return highestSprite;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user