如何用Actionscript改变Flash舞台的坐标原点?
我想我以前这样做过,但找不到代码。
Flash 与许多其他图形框架一样使用左上角作为坐标原点 (0,0),因为这是底层内存模型的惯例。
但如果原点位于舞台中心,对于我的计算来说会更简单,因为所有游戏都围绕中心旋转并使用大量三角学、角度等。
是否有一些内置方法,例如 Stage::setOrigin( uint, uint );
或者类似的东西?
I think I did this before but can't find the code.
Flash as many other graphical frameworks use the top-left corner as the coordinate origin (0,0) because it's how the underlying memory model is by convention.
But it would be really simpler for my calculations if the origin was in the center of the stage, because all the game revolves around the center and uses a lot of trigonometry, angles, etc.
Is there some built-in method like Stage::setOrigin( uint, uint );
or something like that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建一个重写 x 和 y setter 和 getter 的类来处理计算。舞台上的任何 MovieClip 都应该扩展这个新类。
奖励:您可以随时更改原点值,因此它不必位于舞台的中心。
Create a class that overrides the x and y setters and getters to handle the calculations. Any MovieClips on stage should extends this new class.
Bonus: you can change the origin values whenever you want, so it doesn't have to be at the center of the stage.
创建一个 MovieClip 或 Sprite,并将其作为根对象添加到舞台(而不是添加到舞台),位置为 stage.width/2、stage.height/2。然后当您将游戏对象添加到其中时。将游戏对象添加到该剪辑内的 0,0 处,它们将位于舞台中央。
Create a MovieClip or Sprite and add that to the stage as your root object (instead of adding to the Stage) at stage.width/2, stage.height/2. Then when you add your game objects to that instead. Add your game objects at 0,0 inside of that clip and they will be centered on the stage.