Hello. Right I have game that I'm making called Happy Monster Island. So far it works great a title screen comes up with a flashing press start message you hit space then a menu appears with options you hit A and the game starts then you start hitting X and you can skip through all these bubbles.
Everything works the way its supposed to(there's even a cool FF7 noise when you skip the text bleep bleep it goes!) but I've come to a point where the user has to make a choice to go one way or the other and I can't do that. Because all the keystrokes actually do is advance the main timeline one frame. Theres a movie clip on each frame which is sometimes just a picture. Previously I had been trying to jump to a certain frame and play but I had problems so I had the temporary solution of apply code to the whole thing to make these keys go next frame. So here's my code anyway. I can't use buttons because I'm porting it onto a system without a cursor(hopefully)
keyListener = new Object();
keyListener.onKeyDown = function() {
x=Key.getAscii();
if(x==32){
nextFrame();
}
}
Key.addListener(keyListener);
keyListener = new Object();
keyListener.onKeyDown = function() {
x=Key.getAscii();
if(x==65){
nextFrame();
}
}
Key.addListener(keyListener);
keyListener = new Object();
keyListener.onKeyDown = function() {
x=Key.getAscii();
if(x==88){
nextFrame();
MyEffect_sound.start(0,0);
}
}
Key.addListener(keyListener);
So I don't even know what my problem is to be honest but if I could have extra functions for the same keys in order or have actionscript only affect one frame or something I could have enough interactivity to get by.
Monster game needs to be able to reuse keystrokes(I think)
Started by Nicodemus36Q, Feb 23 2007 09:16 AM
5 replies to this topic
#1
Posted 23 February 2007 - 09:16 AM
#2
Posted 23 February 2007 - 11:10 AM
try tracing the x variable on keypress. Maybe you've screwed up your numbers. If the trace shows undefined, then you know its a problem with your code.
Edit:
You might also want to check scope of what you are trying to do within your listener object. Put traces in to see where your code is going. Helps heaps in debugging.
Edit:
You might also want to check scope of what you are trying to do within your listener object. Put traces in to see where your code is going. Helps heaps in debugging.
Edited by Pax, 23 February 2007 - 11:14 AM.
#3
Posted 23 February 2007 - 02:01 PM
Well when I had sort of the same code in but also with something that "traced" it was reporting that "you have pressed 12" etc. In terms in scope I suppose what would be nice is to make it more local. I tried changing some of the names of the variables and putting in "this." in front of things but it didn't work. If I could create another function object maybe...
Can I wrap it inside a private function? Did that make sense?
Can I wrap it inside a private function? Did that make sense?
Edited by Nicodemus36Q, 23 February 2007 - 02:07 PM.
#4
Posted 23 February 2007 - 04:15 PM
I think I've sorted it. I simply used the remove keylistener method then made a new one. This seems to allow me to change the function of certain keys as I go and hopefully to have enough manipulation of the timeline.
#5
Posted 23 February 2007 - 07:13 PM
There is no need to keep adding the Key Listener to the key:
keyListener = new Object();
keyListener.onKeyDown = function() {
x = Key.getAscii();
if(x == 65) {
nextFrame();
} else if(x == 88) {
nextFrame();
MyEffect_sound.start(0,0);
} else if(x == 32) {
nextFrame();
}
}
Key.addListener(keyListener);
Edited by Ben, 23 February 2007 - 07:16 PM.
#6
Posted 25 February 2007 - 06:22 PM
Oh wow, I totally missed the fact you had 3 different listeners that were overwriting each other. Good catch Ben.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
