View Full Version : help with staying on frame
Sensible
April 18th, 2006, 12:19 AM
I recently started my a new game where you move the cursor (controlled by the arrow keys) and you can select different modes n stuff. Basically identical to Gran Turismo 4 without the extreme depth. Anyways, everything's working fine except for the fact that I can't get it to stay on the frame which I want when you select "Buy a Car" mode. What happens is that if you try and select it, it shows the frame for as long as the Enter key is held. What I'm wondering is how to fix this so that once you select "Buy a Car" mode, it stays on the frame which I want it to.
(could not include .fla because it was too big)
Here's the code on the "Buy a Car" MC:
onClipEvent(enterFrame){
if(this.hitTest(_root.cursor)){
if(Key.isDown(Key.ENTER)){
gotoAndStop("carSelection");
} else {
gotoAndStop("buyCar");
}
} else {
gotoAndStop(1);
}
}
ricer
April 18th, 2006, 01:25 AM
allright then try this :)
onClipEvent(enterFrame){
if(this.hitTest(_root.cursor)){
if(Key.isDown(Key.ENTER)){
_root.gotoAndStop("carSelection");
} else {
_root.gotoAndStop("buyCar");
}
} else {
gotoAndStop(1);
}
}
and make sure u got the frames a
stop();
Sensible
April 18th, 2006, 04:36 AM
hey ricer, i tried what u suggested. But now when you hover the cursor over the "Buy a Car" option, it doesnt even show up anything let alone display the frame..
Joppe
April 18th, 2006, 05:53 AM
edit: DARN! I missunderstood you.. Uhh.. yeah :(..
theflash
April 18th, 2006, 05:56 AM
It's very simple.... you have that key press check in onEnterFrame event
so when you press enter it goes on that "carSelection" frame but immediately due to onEnterframe event it will go in else... causing to switch back to buycar frame...
get your Key down check code out from onEnterFrame... instead use key listener objects... check help on that...
if you want to confirm it.. put trace above all gotoAndStop lines
Sensible
April 18th, 2006, 06:06 AM
kk thanks will do.
theflash
April 18th, 2006, 06:36 AM
here you go... dont forget to check disable keyboad shortcuts in flash IDE when testing...
Sensible
April 18th, 2006, 06:44 AM
um no offense but how is knowing the keycodes of diff keys sposed to help me?
nathan99
April 18th, 2006, 06:49 AM
no offense but how do you expect to make a gt game without much AS knowledge.. or the will to learn
theflash
April 18th, 2006, 08:51 AM
um no offense but how is knowing the keycodes of diff keys sposed to help me?
something you get to figure out yourself ;)
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.