如何从形状/图形对象读取数据
我想知道是否可以使用 Actionscript 3 获取存储在 Flash 中的形状/图形对象中的数据?
在我的项目中,我希望能够绘制一个形状,然后将该形状中的所有点读入我的脚本中。原因是我需要从这些点生成线条,稍后我可以用它们来检查我的角色速度是否与其中任何一个相交。
I am wondering if it is possible to get the data that is stored in a shape/graphics object in flash using actionscript 3?
In my project I would like to be able to draw a shape and then read all the points in that shape into my script. The reason for that is that I need go generate lines from those points that I later can use to check if my characters velocity intersects with any of them.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以读取 Shape 的所有部分。
新功能添加到 Flash Player 11.6 和 AIR 3.6 中:
flash.display.Grapics.readGraphicsData()
< a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Graphics.html#readGraphicsData%28%29" rel="noreferrer">http://help. adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Graphics.html#readGraphicsData%28%29
示例:
要使用新版本,您必须更新playerglobal.swc
http://www.adobe.com/support/flashplayer/downloads.html
You can read all parts of Shape.
New feature added to Flash Player 11.6 and AIR 3.6:
flash.display.Grapics.readGraphicsData()
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Graphics.html#readGraphicsData%28%29
Example:
To use the new version, you have to update playerglobal.swc
http://www.adobe.com/support/flashplayer/downloads.html
形状信息一旦绘制就无法读取。但如果您正在绘制它,您可以在绘制时存储信息并在以后使用。
You cannot read the shape info once it's drawn. But if you are drawing it, you can store the info at the time of drawing itself and use it later.
好吧,看来这是不可能的,太糟糕了。
我正在做一个 2d 自上而下的赛车游戏,我想沿着赛道的墙壁生成线条,并根据这些线条检查玩家的速度。这样我就能够通过围绕碰撞线法线反射玩家速度并使其从墙壁上反弹来实现一些基本的碰撞响应。有谁对如何在没有实际线条的情况下获得相同类型的碰撞行为有任何好的想法吗?
是否有可能以某种方式重载闪存中的图形对象,以便当我绘制某些内容时它会被记录下来?或者flash IDE不使用Graphics绘图api?
问候
OK, looks like its not possible then, to bad.
I am doing a 2d topdown racing game, and I wanted to generate lines along the walls of the track and check the players velocity against thouse lines. That way I would be able to implement some basic collision response by reflection the players velocity around the normal of the line that it collides with and make it bounce off walls. Does anyone have any good ideas about how to get the same type of collision behavior without the actual lines?
Is it possible to overload the graphics object in flash somehow so that when I draw something it is recorded? Or does the flash IDE not use the Graphics drawing api?
Regards
您不能实例化 Graphics 类或对其进行子类化。但您可以使用自己的自定义图形类。
Now whenever you want to draw something then you can use CustomGraphics.
var cg:CustomGraphics = new CustomGraphics(someDisplacyObject.graphics);
cg.moveTo(0, 0);
cg.drawRect(0, 0, 10,, 200);
...
a:Array = cg.actions;
You can not instantiate or subclass Graphics class. But you can use you own custom graphics class.
Now whenever you want to draw something then you can use CustomGraphics.
var cg:CustomGraphics = new CustomGraphics(someDisplacyObject.graphics);
cg.moveTo(0, 0);
cg.drawRect(0, 0, 10,, 200);
...
a:Array = cg.actions;