开发者

Why aren't the member variables in the following object maintaining their state?

The following two AS files contain statically available public methods. In Mouse.as, the trace statements correctly print the contents of both calls to getLocation(), which returns a Point in space (X,Y).

However, when passing the value from Mouse.as into HitTest.as, target.getLocation() always prints (0,0). Wha开发者_如何学编程t happens to the instance of GameObject when its passed into the second class that causes it to lose its value?

In GameObject

public function getLocation():Point2
{
    return m_location;
}

In Block (extends GameObject)

if (Mouse.isPressing(this))
{
    reset();
}

In Mouse

public static function isPressing(target:GameObject):Boolean
{
    trace("T1: " + target.getLocation());
    trace("M1: " + location);
    return isDown() && HitTest.containsPoint(target, Mouse.getLocation());
}

In HitTest

public static function containsPoint(target:GameObject, location:Point2):Boolean
{
    trace("T2: " + target.getLocation());
    trace("M2: " + location);
    return target.getLocation().GridX == location.GridX && target.getLocation().GridY == location.GridY;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜