符号内的 Flash CS4 / AS3 符号

发布于 2024-10-30 05:28:35 字数 301 浏览 2 评论 0原文

我正在尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

匿名。 2024-11-06 05:28:35

恕我直言,请忘记您的方法,您毫无意义地重新发明轮子,并且最终可能会获得更糟糕的性能。您需要的是像素完美的碰撞检测,并且可能包括基本物理原理,因此我们已经在谈论大量的工作。如果您想以游戏的设计方式构建关卡,请使用它,它会让您大吃一惊,这是多么棒/简单/酷:

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

寒冷纷飞旳雪 2024-11-06 05:28:35

当试图回答这样的问题时,它总是一个猜测,因为有很多未知数。话虽这么说,在编程中,解决问题的方法总是不止几种。检查您的碰撞检测例程 - 如果您使用 hitTestPoint,并且使用 localToGlobal 测试点(mouseX、Y 或您的主要参与者),您可能不会需要测试碰撞对象的 x,y 变量。仔细阅读这两个主题,这个问题可能会变得毫无意义。

无论如何,您可以通过利用 globlaToLocal: 更新 Wall.as 实例中的相对坐标,

public function get curLoc():Point 
{
    return globalToLocal(new Point(this.x, this.y));
}

并从父类中检索它们作为您可以测试的点:

trace(_wall.curLoc);

希望有帮助

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:

public function get curLoc():Point 
{
    return globalToLocal(new Point(this.x, this.y));
}

and retrieve them from your parent class as a point you can then test against:

trace(_wall.curLoc);

Hope that helps

芯好空 2024-11-06 05:28:35

我想你可以通过操纵墙符号的变换属性来完成你想要做的事情,但老实说,我会同意提升系统的观点,并放弃你的碰撞测试例程以进行不同的事情。

您可能不需要为您的游戏全力以赴地使用物理引擎,在这种情况下,只需使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文