Rendering Flash Menu Over the Top of Game Drawn with copyPixels
I'm new to flash but开发者_开发技巧 have plenty of experience developing games, so when I started in flash I ignored pretty much everything that flash could do and just created a buffer the same size as my flash movie and drew my game direct to that with copyPixels.
Now what I want to do is to add a menu to the game and it seems sensible to do make use of flash a little more. I can build a menu no problems in a .fla but can anyone tell me how I can render it over the top of my game?
Thanks.
You could create a class for the menu and attach it via AS (also define it to your library in your IDE), and all it's functionality would be contained within that. I can provide a simple example, if you'd like.
Updated sample:
Create a class for your navigation - call it Navigation.as (same directory as your fla)
package
{
import flash.display.*;
public class Navigation extends Sprite
{
public function Navigation()
{
addEventListener ( Event.ADDED_TO_STAGE, init );
}
private function init ():void
{
// position your nav
this.x = 0;
this.y = 0;
// attach button functionality here
}
}
}
In your flash, right-click -> Properties, on your navigation MC in your library and do this:
Check "Export for ActionScript"
Baseclass: "Navigation"
Then in your main AS, to add it to your stage, you can do this:
var _nav:Navigation = new Navigation();
addChild(_nav);
As long as your addChild(_nav)
after your game is built, it will be on the top.
Hope this helps.
I can elaborate if needed. Feel free to ask. Hope this helps.
Looks like you just need something simple so just create a sprite and add it to the stage when you need your menus and remove it when you don't.
The way display objects work in flash you can build your whole menu in the Sprite (or Movie Clip) and it will be in one tidy place.
精彩评论