精灵不在as3中显示

时间:2013-07-11 02:01:48

标签: actionscript-3

我的游戏中有一个类告诉精灵产生,这个类是MovieClip,附带代码。我在这个类上调用spawn()函数并使用图形API为它绘制精灵。生成函数如下:

public function spawn(){
        this.addChild(window)
        window.x = 5
        window.y = 10
        window.width = this.width - 10
        window.height = this.height - 10
        window.graphics.clear()
        window.graphics.drawRect(5, 10, this.width - 10, this.height - 20)
        window.graphics.beginFill(0xFFFFFF, 1)
        trace(window.visible)
}

问题在于,尽管window跟踪返回visible,但未显示子true。在此先感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

尝试:

window.graphics.clear()
window.graphics.beginFill(0xFFFFFF, 1)
window.graphics.drawRect(5, 10, this.width - 10, this.height - 20)
window.graphics.endFill();

并确保您添加此window的课程也在舞台上。

相关问题