|
-
[RESOLVED] Buttons in MovieClip Don't Work
I'm trying to make a game and, when you encounter enemies or go into a building, your x and y coordinates are recorded as variables and then loaded when you exit. I was trying to make this happen using hitTest but couldn't get it to work, so I am now trying to make a menu appear with buttons, such as "Enter" or "Leave" and "Fight" or "Run".
Problem with this is that i can't get the menu to appear only when the character hitTests an enemy or door, it is constantly there. I tried resolving this by making the menu a movieclip with 2 frames, one empty and one with the movie, this makes the menu appear on collision, but the button does not work properly. I also tried using the alpha values, but the button remains in the middle of the screen invisible.
So basically I am asking for suggestions on how to solve this problem and if you need more specific information just ask
(BTW using Flash 8 but would like to keep it compatible with Flash MX)
(I have another problem to be solved as well but it's not that major, yet)
Thanks.
Last edited by Work!; 09-27-2008 at 07:45 PM.
-
Intermediate Game Dev
Why don't you just have to frames for the menu?
So basically this would go into the menu movie clip
PHP Code:
onClipEvent(enterFrame) { if (_root.door.hitTest(_root.character._x, _root.character._y, true) == true) { this.gotoAndStop(2); //The frame where the menu with the buttons is on } else { this.gotoAndStop(1); //Blank frame } }
That should do it...
Needs an update... 
-
Tried that, but then the button doesn't work.
PHP Code:
on (release) { characterx = backg._x; charactery = backg._y; _root.gotoAndStop("rfight"); }
I have that on the "fight" button (rfight being the frame with the fight) and when the button is independently on the stage it works fine ( im testing it using dynamic text box) but once it is within a movieclip it comes up with either nothing or "undefined"
(and if your wondering why is is backg's coordinates, it is because i'm making the background move, while the character just stays still in the centre)
-
Intermediate Game Dev
Could you please upload the *.fla?
I'll have a look then...
Needs an update... 
-
bit big, is there a site where i can host it?
-
Intermediate Game Dev
^I think I see what you did wrong...try this:
PHP Code:
on (release) { _root.characterx = backg._x; _root.charactery = backg._y; _root.gotoAndStop("rfight"); }
Remember you have to change the code on other places aswell. When you are requesting characterx/charactery, put a "_root." in front of it.
Needs an update... 
-
maybe i could go back to the alpha idea and make a variable that activates when you encounter an enemy, so that i could say on the button, if variable is true do this and if not do nothing, but when i tried the alpha idea it wasn't working, i had
if (enemy.hitTest(_root.character) {
_root.menu._alpha = 100
}
-
-
mm now it goes to the fight scene, which it didn't before, but the variable remains undefined
o w8, maybe if i added _root.backg._x
-
Intermediate Game Dev
^Which variables are local, and which are being used in other movieClips?
Needs an update... 
-
it works now, i guess no variables were local :b another question though, im using the frame idea, but how can i get the background to stop moving once the menu comes up, cause right now you can keep running around. I have an idea as to how which i'll try out now though...
-
ok all problems fixed, it Work!s 
thanks for the help pseudobot
-
Intermediate Game Dev
No problem man!
Needs an update... 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|