AS3 - 如何找到一个对象相对于舞台的位置? [英] AS3 - How to find the position of an object relative to the stage?
本文介绍了AS3 - 如何找到一个对象相对于舞台的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
pre $
localToGlobal(point)
DisplayObject
将点对象从显示对象的(本地)坐标转换到舞台(全局)坐标。 pre $
//假设(0,0)是左上角
var topLeftStage:Point = myDisplayObject.localToGlobal(new Point(0,0));
//右下角
var bottomRightStage:Point = myDisplayObject.localToGlobal(new Point(width,height));
If I have a rectangle on the stage, how do I find its top left tip (x,y) and the bottom right tip (x,y) in relation to the stage? It strange how I can't find this on google!
解决方案
localToGlobal(point)
of DisplayObject
Converts the point object from the display object's (local) coordinates to the Stage (global) coordinates.
// assuming (0, 0) is top left
var topLeftStage:Point = myDisplayObject.localToGlobal(new Point(0, 0));
// bottom right
var bottomRightStage:Point = myDisplayObject.localToGlobal(new Point(width, height));
这篇关于AS3 - 如何找到一个对象相对于舞台的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文