【问题标题】:How to disable a HIT area in AS2?如何在 AS2 中禁用 HIT 区域?
【发布时间】:2014-11-27 11:40:06
【问题描述】:

如何在 AS2 中禁用 HIT 区域(实例名称为“HIT”的影片剪辑)?

请注意,我不想在被击中后隐藏击中区域。只需要一个禁用它或删除它的实例名称的代码,这样其他对象就不能再次命中它。

【问题讨论】:

  • 这些答案对你有帮助吗?
  • 我的目的(问题)是通过另一种方法实现的,尽管您的回答在其他情况下对我有所帮助。非常感谢你...
  • 你说的是hitArea还是hitTest?
  • 我说的是禁用实例,即 (c1.onEnterFrame)。
    your_mc.hitArea=null;和 your_mc.hitArea=undefined;不工作。

标签: actionscript-2 hittest


【解决方案1】:

如果您希望实例c1在被触摸后变为disabled,您可以这样做:

c1.onEnterFrame = function():Void {
    if (this.hitTest(anotherMovieClip)) {
        delete this.onEnterFrame;
    }
}

hitTest不能出现在onEnterFrame函数为deleted之后。

【讨论】:

  • 你的代码是hitTest而不是hitArea,有区别。
  • @akmozo 没错,我的代码是关于hitTest area,但不是关于hitArea (another movie clip to serve as the hit area for a movie clip)。我认为问题是关于 hitTest... 但我可能是错误的。
  • 我认为他在谈论MovieClip.hitArea,或者可能不是!在这两种情况下,我们都给了他一个解决方案,这是最重要的。
【解决方案2】:

你可以这样做:

your_mc.hitArea = null

或者

your_mc.hitArea = undefined

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多