如何计算精灵的大小? [英] How to calculate the size of a sprite?

查看:27
本文介绍了如何计算精灵的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个精灵,我可以在其中进行一些自定义绘图,但我希望容器知道将精灵正确放置在何处.为此,容器需要知道精灵有多大.UIComponents 会经历一个测量阶段,但 sprite 不会.如何计算精灵的大小?

I have a sprite that I do some custom drawing in, but I would like the container to know where to position the sprite properly. To do this, the container needs to know how big the sprite is. UIComponents go through a measure stage, but sprites don't . How do I calculate the size that a sprite will be?

我正在 Event.ENTER_FRAME 中进行绘图,而且它是动画的,所以我无法提前知道它会有多大.UIComponent 有一个 measure 函数,我想创建类似的东西.

I'm doing the drawing in Event.ENTER_FRAME, and it's animated, so I can't tell ahead of time how big it's going to be. The UIComponent has a measure function and I'd like to create something similar.

推荐答案

据我所知,确切的答案是,您无法提前知道,您必须实际绘制精灵以确定其大小.

The precise answer, as far as I can gather is, you can't tell ahead of time, you must actually draw into the sprite to determine it's size.

这篇关于如何计算精灵的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆