Copy link to clipboard
Copied
Hi i'm really new to coding. I have experience in Animate CC. I am trying to make my first game. Its going slow.
My idea is to make a click to open menu that players will be able to navigate to certain areas of a town i'm making.
The menu will be on the right, like this:
If you scroll over and click it. I want it to open up into the menu like this:
Then I can use the oval buttons to navigate players to whatever area I choose. Or I can make an "X" or something that closes it.
I'm sure this is very easy to do..Thanks for the help!
Nice.
Here is a sample in which I try to keep things as simple as possible to help you understand.
Basically I add a single click listener to the whole stage. Then I check for the name of the current object instance that is receiving the click event.
This is helpful because:
- We keep things simple without many listeners;
- It helps improve performance;
- We don't have to deal with issues and limitations of targeting object instances inside of tweens;
- And we don't spread our code everywhere.
AS3 code:
...
Copy link to clipboard
Copied
Hi.
HTML5 or AS3?
Also, do you want to change the area by setting the x and y values of some display object or do you want to just change frames (meaning each town area in a different frame)?
Please let us know.
Regards,
JC
Copy link to clipboard
Copied
AS3.
I would have to make different frames for each area my player can access. House, shop, etc. I will make an icon visible throughout the entire game where the players can click it to return to the "main town".
All I want is the 1st picture or _menu1 to be visible in the _maintown only. When a player clicks the _menu1 it will turn into/become _menu2 or the second picture. Basically a simple menu listing the places the player can go to when in the town.
I tried using a simple button. On "UP" frame. I chose _menu1. and the rest. (Over, Down, Hit) I chose )_menu2.
It sort of worked. But since _menu2 is much larger than _menu1. it popped up way before reaching the area of _menu1.
if that makes sense.
Copy link to clipboard
Copied
Nice.
Here is a sample in which I try to keep things as simple as possible to help you understand.
Basically I add a single click listener to the whole stage. Then I check for the name of the current object instance that is receiving the click event.
This is helpful because:
- We keep things simple without many listeners;
- It helps improve performance;
- We don't have to deal with issues and limitations of targeting object instances inside of tweens;
- And we don't spread our code everywhere.
AS3 code:
import flash.events.MouseEvent;
function changeArea(e:MouseEvent):void
{
if (e.target)
{
if (e.target.name == "houseButton")
gotoAndStop("house");
else if (e.target.name == "shopButton")
gotoAndStop("shop");
else if (e.target.name == "innButton")
gotoAndStop("inn");
else if (e.target.name == "townButton")
gotoAndStop("town");
}
if (e.target.parent)
{
if (e.target.parent.name == "menu")
e.target.parent.play();
}
};
stop();
if (!stage.hasEventListener(MouseEvent.CLICK))
stage.addEventListener(MouseEvent.CLICK, changeArea);
FLA download:
animate_cc_as3_navigation_menu.zip - Google Drive
Please let me know if you don't understand something, if you need to add, fix, or improve anything.
Regards,
JC
Find more inspiration, events, and resources on the new Adobe Community
Explore Now