符号内的 Flash CS4 / AS3 符号
我正在尝试在 Flash CS4 中创建一个多层次的地下城冒险。该布局是由名为 Level 的符号创建的实例,该符号内有多个墙子符号(墙),即 Wall 的实例。 Wall.As 调用了一个碰撞例程来阻止玩家穿过墙壁。 水平线是围绕中心点 (0,0) 绘制的。 当我在 Level(关卡)舞台上创建实例时,碰撞测试器使用 0,0 左右绘制的墙壁的 xy 坐标,而不是舞台上出现的“真实”xy。 所以我需要知道的是如何使用实时舞台信息“更新”每个墙子符号的 xy,覆盖父级中绘制的 XY。不幸的是,它必须更新(我不能保持静态),因为级别很大,所以必须滚动。
谢谢你的建议。
I'm trying to create a multi-level dungeon adventure in Flash CS4. The layout is an instance created of a symbol called Level, within the symbol are multiple wall subsymbols (wall), instances of Wall. There is a collision routine to stop the player walking through the walls, called from Wall.As.
Level is drawn about the centre point (0,0).
When I create an instance on the stage of Level (level), the collision tester is using the xy coordinates for the walls drawn about 0,0, not the "real" xy where it's appearing on the stage.
So what I need to know, is how to "update" the xy for each wall subsymbol with the live stage information, overriding the XYs drawn in the parent. It has to be updated unfortunately (I can't keep it static), as the levels are big so have to scroll.
Thanks for your advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
恕我直言,请忘记您的方法,您毫无意义地重新发明轮子,并且最终可能会获得更糟糕的性能。您需要的是像素完美的碰撞检测,并且可能包括基本物理原理,因此我们已经在谈论大量的工作。如果您想以游戏的设计方式构建关卡,请使用它,它会让您大吃一惊,这是多么棒/简单/酷:
http://www.gotoandlearn.com/play.php?id=135
With all due respect forget your approach, you're reinventing the wheel for nothing and probably to end up getting worse performance. What you need is pixel-perfect collision detection and probably including basic physics so already we're talking a huge amount of work. If you want to build levels in a design way for a game, use this, it'll blow your mind how awesome/easy/cool this is:
http://www.gotoandlearn.com/play.php?id=135
当试图回答这样的问题时,它总是一个猜测,因为有很多未知数。话虽这么说,在编程中,解决问题的方法总是不止几种。检查您的碰撞检测例程 - 如果您使用 hitTestPoint,并且使用 localToGlobal 测试点(mouseX、Y 或您的主要参与者),您可能不会需要测试碰撞对象的 x,y 变量。仔细阅读这两个主题,这个问题可能会变得毫无意义。
无论如何,您可以通过利用 globlaToLocal: 更新 Wall.as 实例中的相对坐标,
并从父类中检索它们作为您可以测试的点:
希望有帮助
Its always a guess when trying to answer questions like this, as there are a lot of unknowns. That being said, in programming, there are always more than a few ways to solve a problem. Examine your collision detection routine - if you worked with hitTestPoint, and the point that was being tested (mouseX,Y or your main actor) with localToGlobal, you likely wouldn't need to test for the x,y variables of your collision objects. Read up on those two subjects and this question might be rendered moot.
At any rate, you could update relative coordinates in your Wall.as instance by leveraging globlaToLocal:
and retrieve them from your parent class as a point you can then test against:
Hope that helps
我想你可以通过操纵墙符号的变换属性来完成你想要做的事情,但老实说,我会同意提升系统的观点,并放弃你的碰撞测试例程以进行不同的事情。
您可能不需要为您的游戏全力以赴地使用物理引擎,在这种情况下,只需使用 hitTestObject 来进行碰撞检测。
I suppose you could accomplish what you're trying to do by manipulating the transform property of the wall symbols, but honestly I would concur with Ascension Systems and just abandon your collision testing routine for something different.
You may not need to go all out with a physics engine for your game, in which case just use hitTestObject to do the collision detection.