在ActionScript 3雪碧我如何绘制文字? [英] How do I draw text in an ActionScript 3 sprite?

查看:130
本文介绍了在ActionScript 3雪碧我如何绘制文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些精灵的用户可以操纵,左右拖动和调整大小。现在,我希望能在那些精灵显示文本。我试过很多,可能是愚蠢的,方式。就像从标签继承并添加一个Label孩子的精灵,但没有文字显示出来。

I have some sprites that the users can manipulate, drag around and resize. Now I'd like to be able to display text in those sprites. I've tried lots of, probably stupid, ways. Like inheriting from Label and adding a Label child to the sprite, but no text shows up.

一个令人不安的事:从标签继承我得到的文本显示出来,如果​​我运行在调试和检查我的标签子类的实例

One disturbing thing: Inheriting from Label I get the text to show up if I run in the debugger and inspect my Label subclass instance.

我有这种感觉,我失去了一些东西真的很明显。这是怎么做的,正确的方法是什么?

I have this feeling I'm missing something really obvious. How is this done, the proper way?

推荐答案

我会带更多的东西低级别比标签去。使用文本字段,并将其添加为一个孩子的雪碧:

I would go with something more low-level than Label. Use a TextField and add it as a child to the Sprite:

var text:TextField = new TextField();
text.text = "hello world";
addChild(text);

请注意:你的文本将不会显示出来,如果​​雪碧转动,字体没有嵌入

Note: your text will not show up if the Sprite is rotated and the fonts are not embedded.

这篇关于在ActionScript 3雪碧我如何绘制文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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