AS3:使用ActionScript设置DisplayObject的注册点? [英] AS3: setting registration point of a DisplayObject with actionscript?

查看:116
本文介绍了AS3:使用ActionScript设置DisplayObject的注册点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你会如何设置报名点上雪碧或通过动作形状(我知道这是微不足道的使用Flash,但我需要完全做到这一点在动作)

How would you set the registration point on a Sprite or Shape via actionscript (I know this is trivial using Flash, but I need to do it purely in actionscript)

推荐答案

Flash播放器API不公开这一点。我相信这是因为Flash其实烤的注册点到形状数据时,它创建的SWF。因此,有没有实际的注册点移动(而不是,你会移动形状数据......如果Flash播放器,让您编辑形状数据!)。

The Flash Player API doesn't expose this. I believe this is because Flash actually bakes in the registration point into the shape data when it creates the SWF. Thus, there's no actual registration point to move (instead, you'd move the shape data... if the Flash Player let you edit shape data!).

我总是通过简单地养育我的精灵/形状到另一个的DisplayObject解决这个问题。所以,如果我有spriteA,并希望其注册点设置为(15,35),我会做这样的:

I always solve this by simply parenting my sprite/shape to another DisplayObject. So, if I have spriteA and want to set its registration point to (15, 35), I'd do this:


var spriteB:Sprite = new Sprite();
spriteB.addChild(spriteA);
spriteA.x = 15;
spriteA.y = 35;

然后从此参考spriteB无处不在我previously指spriteA。

And then from then on refer to spriteB everywhere I was previously referring to spriteA.

这篇关于AS3:使用ActionScript设置DisplayObject的注册点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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