View Full Version : door problems
mongoose9990
September 9th, 2006, 11:20 PM
:beam: hi,
im currently working on a pokemon game and i am trying to make it when you can go up to the door and press enter it goes inside but with the code im useing which i just made up and put on the door onClipEvent
(enterFrame) {
if (Key.isdown(key.ENTER)) {
play();
}
}
works but i can go inside where ever i am so do i need to put a diffrent code or can i just not do it?
LittleFenris
September 9th, 2006, 11:39 PM
You'll need to define a variable that says they are at the door or not and if they are at the door then it allows the code you already have done. The easiest way to figure out of they are near or right on the door is a hitTest between the door and the character and if the character is at the door you allow the player to hit Enter to go in the room but if the character isn't at the door then it doesn't do anything. These are both very easy things to do if you search for hitTest and variables on this site.
Something like this (put on first frame instead of on the door):
character_mc.onEnterFrame = function() {
if (this.hitTest(door_mc)) {
if (Key.isdown(key.ENTER)) {
play();
}
}
}
nathan99
September 9th, 2006, 11:46 PM
cant see why a variable is necessary
onClipEvent (enterFrame) {
if (Key.isdown(key.ENTER) && _root.character.hitTest(this)) {
play();
}
}
mongoose9990
September 9th, 2006, 11:49 PM
thanks
:stunned:
mongoose9990
September 9th, 2006, 11:52 PM
lol what hit test should i put on the door im not to good at those :blush:
mongoose9990
September 9th, 2006, 11:56 PM
please
mongoose9990
September 10th, 2006, 12:00 AM
please can u tell me what one please i beg
Joppe
September 10th, 2006, 12:07 AM
Well if you wait a bit longer then 4minutes you could get an answer you know.
mongoose9990
September 10th, 2006, 12:09 AM
lol ok
LittleFenris
September 10th, 2006, 12:45 AM
lol ok
Did you even try the code he gave you? You don't need a hitTest on the door if its already on the character.
mongoose9990
September 11th, 2006, 02:21 AM
i tried that code but it done the same thing ?
Now what?
mongoose9990
September 11th, 2006, 02:24 AM
should i have my orriginal code on my char and put your code on the frame?
nathan99
September 11th, 2006, 03:54 AM
put that code on the door.
and seriously u are really annoying me. WTF with the one post each 4 minutes!!!!!!!!! Either put it all into one post or forget about it.!
mongoose9990
September 11th, 2006, 05:59 AM
im really confused i put it on the door but little fenris is saying to put it on the frame?
and is there another way like you walk up to the door and you go inside?
:hugegrin:
LittleFenris
September 11th, 2006, 10:22 AM
im really confused i put it on the door but little fenris is saying to put it on the frame?
and is there another way like you walk up to the door and you go inside?
:hugegrin:
You can put the code on the door, or the first frame. I like to put all my code on the first frame so I don't have to hunt around to find code if I need to change something. If its all on the first frame I know where to go. Using nathan99s way is just fine too. Pick whatever works best for you.
nathan99
September 11th, 2006, 06:38 PM
You can put the code on the door, or the first frame. I like to put all my code on the first frame so I don't have to hunt around to find code if I need to change something. If its all on the first frame I know where to go. Using nathan99s way is just fine too. Pick whatever works best for you.
If I were you, mongoose, I would move ALL your code to the frame, That's what I would do. Using frame-based programming is generally a lot easier and codes on movie clips is actually gone in flash 9 :o
LittleFenris
September 11th, 2006, 07:19 PM
...and codes on movie clips is actually gone in flash 9 :o
Wow, glad I got used to doing frame based coding a while ago then.
mongoose9990
September 12th, 2006, 03:27 AM
iv tried both many time could i please send the file and some one can do it for me?
LittleFenris
September 12th, 2006, 10:55 AM
Is the file small enough to put as an attachment here on the forum? If not PM me and I'll give you my email address to send the file to and I'll see if I can help.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.