Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-13-2011, 01:05 PM   #1
smks
Registered User
 
Join Date: Dec 2011
Posts: 20
Cool [AS3] Game spacebar press loop

I am making a game where.. a character is standing on the left side of a cliff. Because I am a newbie AS3 programmer, I am using simple timeline navigation. Let me explain:

Character stands on cliff. He clicks on platform on other side of swamp. This then moves him on to another frame where I have looped a group of frames. He does an animation that makes himself prepare to jump. They all have different levels of whether he will make it to the other side.

I have labelled them all like this:

startframe is C2.1
Trips over into water is frame label C2.2
Jumps but doesnt reach platform C2.3
Jumps and successfully reaches over side C2.3

here is the code below for each timed event.
__________________________________________
stage.addEventListener(KeyboardEvent.KEY_DOWN, spacePress_01);

function spacePress_01(evt:KeyboardEvent):void {
if (evt.keyCode==Keyboard.SPACE) {
gotoAndStop("(whatever frame pressed");
}
}
______________________________________________

so if the user presses space too early he wont make the platform. If he doesnt press anything at all he trips into the water. Then I have a frame action that says gotoandstop at C2 which is back to start. (when he has to click other platform to intiate the game again. Understood?

However when that frame is looped back to start the frame rate goes OUT OF CONTROL!

It starts speeing up the frame rate... then eventually coming to a stable FPS. (24)

I tryed this on the frames
___________________________________

stage.framerate = 24;

didnt do anything.
And also with the spacepress I have to click on stage before it functions. how can i give it focus?

Thanks
Attached Thumbnails
Click image for larger version

Name:	Capture.PNG
Views:	55
Size:	140.8 KB
ID:	37857  
smks is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:13 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.