as3 中的塔防游戏帮助

发布于 2025-01-03 04:37:34 字数 1286 浏览 0 评论 0原文

我一直在研究塔防游戏的教程(http://www.guahanweb.com/2009/01/31/tower-defense-in-as3-part-iv/),但我在制作第二张地图/道路时遇到了麻烦。我已经能够改变道路了。 (如果你还没有从源文件中弄清楚他在MagicTD文件中给出了this.points =[[__]])我已经替换

this.points = [[2, -1], [2, 5], [6, 5], [6, 16], [28, 16], [28, 4], [12, 4], [12, 19], [22, 19], [22, 12], [36, 12]];
            this.grid_size = 16;

            // this.setupTarget();
            this.drawBackground();
            this.setupMap();
            this.setupTimers();
            this.setupListeners();

map1btn.addEventListener(MouseEvent.CLICK, clickmp1);



            this.grid_size=16;

and(map1btn是一个按钮) clickmp1 是

public function clickmp1(event:MouseEvent) {
            this.points=[[1,-1],[2,5],[6,5],[6,16],[28,16],[28,4],[12,4],[12,19],[22,19],[22,12],[36,12]];
this.setupTimers();
            this.drawBackground();

            this.setupMap();
            this.setListeners();



        }

(检查其余部分的源文件(http://code.guahanweb.com/viewsource/td04/))

发生的事情是敌人正在地图和网格下面。

谢谢

雷神

I have been working off of a tutorial of a tower defence game(http://www.guahanweb.com/2009/01/31/tower-defense-in-as3-part-iv/) but I have been having trouble with making a second map/road. I've gotten to be able to change the road. (If you haven't figured out from the source file that he gives its the this.points =[[__]] in the MagicTD file) I have replaced

this.points = [[2, -1], [2, 5], [6, 5], [6, 16], [28, 16], [28, 4], [12, 4], [12, 19], [22, 19], [22, 12], [36, 12]];
            this.grid_size = 16;

            // this.setupTarget();
            this.drawBackground();
            this.setupMap();
            this.setupTimers();
            this.setupListeners();

with

map1btn.addEventListener(MouseEvent.CLICK, clickmp1);



            this.grid_size=16;

and (map1btn is a button) and clickmp1 is

public function clickmp1(event:MouseEvent) {
            this.points=[[1,-1],[2,5],[6,5],[6,16],[28,16],[28,4],[12,4],[12,19],[22,19],[22,12],[36,12]];
this.setupTimers();
            this.drawBackground();

            this.setupMap();
            this.setListeners();



        }

(check the source file for the rest (http://code.guahanweb.com/viewsource/td04/))

whats happening is the enemy is going under the map and the grid.

thanks

thor

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

陈甜 2025-01-10 04:37:34

听起来您需要将地图设置在所有内容后面。为此,您需要执行以下操作:

this.setChildIndex(yourMapInstanceName, 0);

MovieClip.setChildIndex() 的文档

这假定所涉及的所有内容都将“this”作为公共父级。

或者,在所有东西上面扔一些东西:

this.setChildIndex(yourMapInstanceName, this.numChildren - 1);

It sounds like you need to set your map back behind everything. To do that you'd do something like:

this.setChildIndex(yourMapInstanceName, 0);

Docs for MovieClip.setChildIndex()

This assumes everything involved has "this" as a common parent.

Alternatively, to throw something on top of everything:

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