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

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

问题描述

你将如何通过 actionscript 在 Sprite 或 Shape 上设置注册点(我知道这使用 Flash 很简单,但我需要完全在 actionscript 中完成)

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 Player API 没有公开这个.我相信这是因为 Flash 在创建 SWF 时实际上将注册点烘焙到形状数据中.因此,没有要移动的实际注册点(相反,您需要移动形状数据...如果 Flash Player 允许您编辑形状数据!).

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;

然后从那时起,在我之前提到 spriteA 的任何地方都提到 spriteB.

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

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

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