在游戏主菜单主菜、游戏

2023-09-08 15:05:23 作者:给朕换尿片

我创建了一个菜单,我的游戏按键和诸如此类的东西作为命名菜单单独的FLA文件。我实际的比赛被称为Game.fla另一个FLA文件。我想知道的最好的办法是在比赛前戏加载此菜单是什么?

I have created a menu for my game with buttons and whatnot as a separate .fla file named Menu. My actual game is another .fla file called Game.fla. I was wondering what the best way would be of loading this menu before the game plays?

感谢。

推荐答案

我会建议你创建一个与名为.swc你Menu.fla,然后只是添加名为.swc你Game.fla

I would suggest that you create a .swc with your Menu.fla, and then just add that .swc to your Game.fla

如果您使用的是CS6,请确保您设置联动你想在你的code创建实例的任何影片剪辑。

If you are using CS6, make sure that you are setting linkage for any MovieClips you want to create instances of in your code.

在库路径选项卡上的动作设置,您可以添加在编译时将被纳入到你的.swf一个名为.swc。

In the actionscript settings on the library path tab, you can add a .swc that will be included into your .swf when compiling.

在你的code,你现在可以创建一个实例,并添加到显示列表中:

In your code, you can now create an instance and add to the display list :

// Assuming MainMenu was a movieclip with linkage set in your .swc 
var mainMenu:MainMenu = new MainMenu;
addChild(mainMenu);

我要指出,这并不在运行时加载的名为.swc,它包括以名为.swc您瑞士法郎在编译时。我建议过载在多数情况下一个.swf此方法。情况下,我可能没有,是,如果有是没有必要一下子大量的内容。这将允许您尽量减少你使用的内存量,并减少你的主要瑞士法郎的瑞士法郎大小,所以它加载速度更快。

I should note that this does not load the .swc at runtime, it includes the .swc to your .swf at compile time. I would recommend this method over loading a .swf in most cases. Cases where I might not, is if there was a large amount of content that wasn't needed all at once. That would allow you to minimize the amount of memory you were using and reduce the .swf size of your main .swf so it loads quicker.

每当你加载瑞士法郎在运行时要添加另一层复杂性,所以我不推荐它,除非你有一个很好的理由这样做。从你所描述的,这听起来并不像一个情况下,我会在运行时加载外部瑞士法郎。

Anytime you are loading .swf's in at runtime you are adding another layer of complexity, so I'd not recommend it unless you do have a good reason to do so. From what you have described, this doesn't sound like a situation where I'd load an external .swf at runtime.