Count Up Timer For Game
I used this code to make a counter.......... It works the first time, then, when the game goes back to the beginning the counter goes double time... Then, you restart and the counter goes tripel.... I have it going back to the first frame which sets the time back to 1...
What am I doing wrong. Thank you...
Here's the code
setInterval(countup, 1000);
time = 1;
function countup() {
time += 1;
}
FlashKit > Flash Help > Flash Newbies
Posted on: 08-29-2006, 12:28 AM
View Complete Forum Thread with Replies
Sponsored Links:
Count Down Timer Changes In Count Up
Is it possible to make a count up timer (from a specific date, birthday for exemple) from the count down timer ?
I've tried to change a few things (I'm very bad in programming) but I can't get the date properly.
If not, do somebody know a count up timer (.fla) that I can use ?
Thanks, thanks, thanks
Frankie
View Replies !
View Related
Count Down Timer Changes In Count Up
Is it possible to make a count up timer (from a specific date, birthday for exemple) from the count down timer ?
I've tried to change a few things (I'm very bad in programming) but I can't get the date properly.
If not, do somebody know a count up timer (.fla) that I can use ?
Thanks, thanks, thanks
Frankie
View Replies !
View Related
Count Down Timer
hi anyone know how to put a script on the main movie to make a countdown timer(global variables or stuff),so that when the user go to other scenes or within the main scene, after certain of time, the movie replay or reset to original state?
i would like to do a simple game for sch project, hope u can help.
thanks.
for example,
i set the count down time to 30 secs then it start counting when user have no mouse action.
really appreciated if anyone can help.
thks
View Replies !
View Related
Count Down Timer
Does anyone know how I can create a count down timer in actionscript?
I want to delay an event until a certain amount of time has passed.
Any help would be great!!!
Thanks
View Replies !
View Related
Timer To Count Down
i have videos in a flash presentation and i want people to be able to see how much time is left on them.
the only controllers i have on them now are some basic buttons- play, ff, rw, pause.
i thought the easiest way to show how much time is left would be to have a dynamic text field that counts backwards in relation to how much of the video has been played.
the time wouldnt relate to data loaded (like a preloader would) because the vids are on a cd so the whole video is already loaded.
i have followed a few text book tutorials but i cant really adapt them to my situation (action script is not my forte).
anyone know how to do this? im sure its easy but i dont know where to start.
also, i have no idea what im doing, so please- i need things explained to me!
cheers
View Replies !
View Related
Count Down Timer ?
Looking for an open source file just like this:
http://www.flashkit.com/movies/Utili...0276/index.php
except this one counts time forward. I need to count down until a specified time. (I'd modify that file but the movie files are currupt)
edit: I think i found one....wow, had to search deep but I got one.
View Replies !
View Related
Count Up Timer
Hi, I was hoping someone could give me some help. I am trying to create a count up timer for my flash designed CV, it needs to sit in my flash movie and be constantly counting up in years days hours minutes seconds and milliseconds from the date i started my professional career. for instance..
06 years 224 days 04 hours 15 minutes and 33 seconds 712 milliseconds
professional experience.
I already have a flash file for a counter that counts down to a certain date and am wondering if it is possible to reverse the timer and put in the time and date i started my career so it keeps count for me and tells potential employers how much experience I have. I also need to add in years as the countdown timer only counts in days.
I have uploaded the file if anyone needs to look at the code... or would be kind enough to edit it for me? or let me know if it would be easier to build a different one and how.
http://www.boojak.com/counter/countdown.fla
thanks
View Replies !
View Related
[F8] Count Up Timer
Hello,
I am trying to find a way to script a count up timer. The timer would have seconds(no milliseconds), minutes, and hour fields. This timer will be implemented into a game to show how long the person has been playing it. I would like it to start as soon as the .swf is opened.
Thank you for any insight!
View Replies !
View Related
Count Down Timer?
I can't get this timer to work.What am I missing?
this.onEnterFrame = function(){
var todayate = new Date();
var currentYear = today.getFullYear();
var currentTime = today.getTime();
var targetDateate = new Date(currentYear,11,25);
var targetTime = targetDate.getTime();
var timeLeft = targetTime - currentTime;
var sec = Math.floor(timeLeft/1000);
var min = Math.floor(sec/60);
var hrs = Math.floor(min/60);
var days = Math.floor(hrs/24);
sec = string(sec % 60);
if (sec.length < 2) {
sec = "0" + sec;
}
min = string(min % 60);
if (min.length < 2) {
min = "0" + min;
}
hrs = string(hrs % 24);
if (hrs.length < 2) {
hrs = "0" + hrs;
}
days = string(days);
var counter:String = days + ":" + hrs + ":" + min + ":" + sec;
time_txt.text = counter;
}
View Replies !
View Related
Count Down Timer
I need some help. I have a web site that till tell the blight of cats and
dogs in shelter and rescues that have a short time to live before they are
put down to make room for other stray pets.
I need a dynamic countdown timer in black with white numbers that countdown
days, hours, and minutes (possibly seconds for dramatic effect). Anywhere I
can find such a movie? I found a bunch of cheesy ones online and a bunch
that do way too much.
When the rescue or shelter moves the pet to LCP status, they will enter a
date into the database. I need the time to use that as the starting point
and count down till that date and time arrives. I am using coldfusion as the
dev coding for the site.
Please let me know where I can find such a movie or how much it will cost to
have one done.
Thanks.
View Replies !
View Related
Count Down CLOCK/TIMER
hello.
I am trying to create a timer which counts down from 4:00 minutes to 0:01 second. What would be the best way to go about doing something like this?
Any suggestions, help, or a point in the right direction would be greatfully appreciated.
cheers-
ryan
View Replies !
View Related
What's Wrong? - Timer Count Down (mx)
In a game I have a mc on the stage with this actionscript:
onClipEvent (load) {
startTime = getTimer();
}
onClipEvent (enterFrame) {
currentTime = getTimer();
elapsedTime = Math.round((currentTime-startTime)/1000);
_root.timeRemain = 20-elapsedTime;
if (_root.timeRemain <=0) {
gotoAndStop(20);
}
}
It's not working.... why?!???
The timeRemain just keeps on counting down to negative numbers.
The game loops in 5 frames. Has it anything to do with that?
View Replies !
View Related
Need Count Up Timer For MX 2004- 09:00:00 To 09:30:00
Hello,
Does anyone have or can anyone direct me to actionscript that can count up from 09:00:00 to 09:30:00?
It would need to change the seconds and the minutes. I am a designer with a light understanding of actionscript. Yet I haven't been able to find something I could edit to fit that criteria.
Any help would be greatly appreciated!! I'm in a bind.
Thanks,
J.
View Replies !
View Related
Count Up Timer At 76 Per Minute
Hi,
I am a new user to both Flash MX and this forum and was wondering if anybody could help.
I am trying to create a timer that counts up 76 units for every minute elapsed (I am trying to create a visual pulse timer). I want it to count up from 0 and not have increments of hours/minutes/seconds etc but just count up as one number getting larger. I have downloaded the following script and can't see a way of changing it so that it works. can anyone help?
//initial variables
var timing:Boolean = false;
var paused:Boolean = false;
var remaining:Number;
var elapsedTime:Number;
var elapsedHours: Number;
var elapsedM:Number;
var elapsedS:Number;
var elapsedH:Number;
var startTime:Number;
var remaining:Number;
var hours:String;
var minutes:String;
var seconds:String;
var hundredths:String;
_root.play_btn.onPress = function() {
if(!_root.timing) {
if (_root.paused) {
_root.startTime = getTimer() - _root.elapsedTime;
} else {
_root.startTime = getTimer();
}
//start timer
_root.paused = false;
_root.timing = true;
}
}
_root.stop_btn.onPress = function() {
//stop the timer
_root.timing = false;
//reset the paused variable
_root.paused = false;
//reset the display textbox
_root.timer_txt = "00:00:00:00";
}
_root.pause_btn.onPress = function() {
//only pause if the timer is actually going
if(_root.timing) {
_root.timing = false;
_root.paused = true;
}
}
_root.onEnterFrame = function() {
if (timing) {
//calculate values
elapsedTime = getTimer()-startTime;
//hours
elapsedHours = Math.floor(elapsedTime/3600000);
remaining = elapsedTime-(elapsedHours*3600000);
//minutes
elapsedM = Math.floor(remaining/60000);
remaining = remaining-(elapsedM*60000);
//seconds
elapsedS = Math.floor(remaining/1000);
remaining = remaining-(elapsedS*1000);
//hundredths
elapsedH = Math.floor(remaining/10);
//output to text box
//add a 0 on the front of the numbers if the number is less than 10
if (elapsedHours<10) {
hours = "0"+elapsedHours.toString();
} else {
hours = elapsedHours.toString();
}
if (elapsedM<10) {
minutes = "0"+elapsedM.toString();
} else {
minutes = elapsedM.toString();
}
if (elapsedS<10) {
seconds = "0"+elapsedS.toString();
} else {
seconds = elapsedS.toString();
}
if (elapsedH<10) {
hundredths = "0"+elapsedH.toString();
} else {
hundredths = elapsedH.toString();
}
_root.timer_txt = hours+":"+minutes+":"+seconds+":"+hundredths;
}
};
View Replies !
View Related
Help With ActionScript And A Count Down Timer
HI I have created a movie Clip for a count down timer. The Count down timer movie clip has two layers with only one fame each. The first layer is the actions, the second holds a text field with a variable name timer_txt and this is where the count down timer results are shown.
I have managed to get the timer to go down to zero, however, i need it continue into negative numbers. What I thought was to have a booleen value which will change the timer from subtracting to adding 1. But this does not work... can you please help me with this.
The following is the code in the actions layer on frame one :
Code:
//initial variables
var timing:Boolean = false;
var paused:Boolean = false;
var remaining:Number;
var elapsedTime:Number;
var elapsedHours:Number;
var elapsedM:Number;
var elapsedS:Number;
var elapsedH:Number;
var startTime:Number;
var remaining:Number;
var hours:String;
var minutes:String;
var seconds:String;
var hundredths:String;
var timeOut:String;
startTime = getTimer();
timing = true;
var timeSec:Number;
var timeSecStr:String;
var timeMin:Number;
var timeMinStr:String;
timeSec = 60;
timeMin = 10;
//_root.createEmptyMovieClip("countDown", 10);
//cCenterX = Stage.width/2;
//cCenterY = Stage.height/2;
//_root.countDown.createTextField("myTextField", 1, cCenterX, cCenterY, 30, 20);
//_root.countDown.myTextField.background = true;
//_root.countDown.myTextField.autoSize = "center";
//_root.countDown.myTextField.border = true;
//_root.countDown.myTextField.backgroundColor = 0x00FFCC;
count = 3;
minCount = 9;
timeOut = "F";
myCountDown = function () {
if (this.timeOut == "F") {
count--;
if (count == 0){
var myTextFormat = new TextFormat();
myTextFormat.color = 0xff0000;
this.timer_txt.setNewTextFormat(myTextFormat);
this.timeOut = "T";
}
}
else if (this.timeOut == "T"){
count++;
}
}
countInterval = setInterval(myCountDown, 1000);
this.onEnterFrame = function() {
elapsedH = Math.floor(count/60);
elapsedM = count-(elapsedH*60);
if (timeOut = true){
timer_txt = "-";
}
else if (timeOut = false){
timer_txt = "";
}
if (elapsedH < 10){
timer_txt = "0" + elapsedH;
}else
{
timer_txt = elapsedH;
}
if (elapsedM < 10){
timer_txt += ":0" + elapsedM;
}else
{
timer_txt += ":" + elapsedM;
}
//timer_txt = mincount + ":" + count;
//if (count == 0) {
//
//clearInterval(countInterval);
//timer_txt = "00:00";
//}
}
Please note that there are some redundant variables in there, and while I have been trying to solve this the code has become messy.
View Replies !
View Related
Timer/Date - How To Count The Days Since A Day
If you look at my footer, you will see the Windows XP thing. Rather than editing it every single day, and to set my self a challange, I want to make a Flash SWF that will do it for me I asume using the getDate function.
I am not great at AS, I can drag windows, open URLs and make forms, but noting major like this.
I have looked at the tuts and I can't see anything to sort my problem.
How can I count the days since March 2nd 2002 (when I got XP)?
I have Flash 5 and MX.
Thank you in advance.
View Replies !
View Related
Count-Up Timer: I've Wracked My Brain...can Anyone Help?
Ok, I'm trying to create a count up script that takes a date that I specify and checks the UTC and displays how many days, hours, minutes, seconds have passed since that interval. This is the coding that I have so far and I can't seem to get anything to work. Can anyone help me out?
Code:
dateNow = new Date();
timeNow = dateNow.Date.UTC(year, month, date, hour, min, sec);
dateThen = new Date();
startDate = dateThen.setDate();
difference = (dateNow - startDate);
dayNumber = difference/86400; // 24 hrs * 60 min * 60 sec
days = int(dayNumber);
hourNumber = (dayNumber - days)*24;
hours = int(hourNumber);
minuteNumber = (hourNumber - hours)*60;
mins = int(minuteNumber);
secondNumber = (minuteNumber - mins)*60;
secs = int(secondNumber);
View Replies !
View Related
Preloader GotoAndStop Count Down Timer
I just need this preloader to goto a frame every 10 percent loaded, am sure its a simple fix I just cant figure it out, thanks
Code:
if(countdown == 0 ){
preloader.countdown.gotoAndStop("1")
};
if(countdown == 10 ){
preloader.countdown.gotoAndStop("2")
};
if(countdown == 20 ){
preloader.countdown.gotoAndStop("3")
}
//make the preloader not visible
preloader._visible = false;
//make the bar movie clip inside the preloader width at 0
preloader.bar._xscale = 0;
//define new listener object
var mclListener:Object = new Object();
mclListener.onLoadInit = function(container:MovieClip) {
trace('initialized');
};
//maje the preloader visible when the load starts
mclListener.onLoadStart = function(container:MovieClip) {
preloader._visible = true;
trace('started');
};
//make the bar and percent test show the preloading
mclListener.onLoadProgress = function(mc, w, t) {
trace('progress: '+w+", "+t);
var w = container.getBytesLoaded();
var t = container.getBytesTotal();
countdown = Math.round(w/t*100);
preloader.percent = Math.round(w/t*100)+"%";
preloader.bar._xscale = Math.round(w/t*100);
};
/*make the preloader not visible when its finished loading.
You could add other actions here to make the movie do what ever, like _root.gotoAndStop (whatever) */
mclListener.onLoadComplete = function(container:MovieClip) {
trace("loaded");
};
/* You can use this preloading code to load jpg's also.
So you could add a dynamic text field that says "No Image availible" if there is no image to load*/
mclListener.onLoadError = function(container:MovieClip, errorCode:String) {
trace('not loaded');
};
//fire the MovieClipLoader and attach the listener to it
var container1:MovieClipLoader = new MovieClipLoader();
container1.addListener(mclListener);
container1.loadClip("main10.swf", container);
View Replies !
View Related
Count Down Timer With Stop And Go Function (flash 5 Only)
I have used the folowing code to make the timer count down.
__________________________________________________ __
onClipEvent (load) {
startTime = getTimer();
countFrom = 10;
}
onClipEvent (enterFrame) {
currTime = getTimer();
elapsedTime = currTime-startTime;
timeRemain = Math.round(countFrom-elapsedTime/1000);
_root.time = timeRemain;
if (timeRemain<0) {
_root.gotoAndStop(2);
}
}
__________________________________________________ __
c
can some one please help me with the stop and go functions?
View Replies !
View Related
Count Down Timer, Doesnt Work In January
Hello all,
I have this flash count down timer, it worked fine last year but now it is acting up....for some reason when you put in any date to count down to in january...it adds as many days as it would take to finish off the month, pluss the amount of time i am requesting.
Any help would be great,
I can post the coding on her if anyone would like to try and help me find the bug...
Thanks
Peter
FYI I am using Flash mx 2004 pro
FYI
View Replies !
View Related
Count UP Timer And Html Coding Question
I have two separate questions that I would love to receive help with. I recently started dabling in flash and decided to make some interactive options on my teams website. I ran into some issues, both should be basic and quick answers for any experienced flash users.
1-I need a count UP timer. I will be using this to show how long a member has been on my team. I want to be able to input a date into the action script and it counts up from there. I have found endless count down timers but I could not modify them to count up. It needs to have the year, month, day, minute, second, and millisecond displays on it as well.
2-Is there any way to get flash to recognize html coding on/in a symbol or text field? I want the exported swf to be able to pull html code and embed the received code into certain section of the swf.
Here is the code I want to embed:
(here is the link so you can see what it is)
Xbox Live Gamercard
Here is the code that needs to be embedded:
<iframe src="http://gamercard.xbox.com/R1R%20Phantom.card" scrolling="no" frameBorder="0" height="140" width="204">R1R%20Phantom.</iframe>
I am basically updating our website with new features and interactivity. This code displays your gamer name for your Xbox Live account. Here is the old player profiles:
old profiles
You can see I created a table in the upper left to house the embedded code. Is there any way to do that in flash or will i be forced to create a swf and have to embed the code via dreamweaver/imageready/etc?
I would really appreciate any help that you can guys can give me.
Phantom
View Replies !
View Related
How Do You Make A Count-down Timer For Recording Live Streaming Video
I have flash media server... and I want to setup a countdown timer for recording broadcasts
Here's a Scenario:
User wants to do a Live broadcast.. But.. they don't want to just press record and have it starting Recording their video right that second. They need a Delay or countdown timer that will countdown and then start recording which would allow them to prepare for their Live Broadcasts.
Whats the best way for a script for a user to decide how much time delay they need before Recording Starts?
Ideally it would look like this:
There is a separate window that allows the user to set up a Self-Countdown Timer which will give them time to get ready for their live broadcasts and start a countdown timer and then begin recording once the timer hits 0.
User sets length of Time Delay: 30 seconds, 1 minute, 2 minutes, or even up to 5 minutes.
User presses Start Broadcast or Record Button to start streaming Live Video.
Then.. the Countdown Timer starts... and it displays in Big Digits on the users screen..... "3...2...1... then it says "Broadcasting Live Now!"
Is This Possible? If so, can someone tell me How would I do this?
Hope someone can help
View Replies !
View Related
Count The Rounds In Car Game
I have made a little multiplayer car game by using this script:
http://www.flashkit.com/tutorials/Ga...-825/index.php
Now I want to have a counter that counts the rounds when it passes the finish line. And the game should ends after some rounds.
Can anyone help?
View Replies !
View Related
Count Up For Simple Maze Game
Hi,
I know next to nothing about AS, but I would like to ask a simple question.
Ok, I am trying to make my very simple maze game more 'fun' and 'interesting' by creating a count up or count down in the top corner using ActionScript (if it's possible) - please refer me to tutorials where possible if needed.
Count up - Viewer competes to the end and tries to beat their best time.
Count down - Viewer has a set time to complete all 25 stages.
Both AS for the count up and down would be good (the viewer gets to choose which mode they want to play)
Thanks!
View Replies !
View Related
[race Game] Howto Count Laps?
Hi all, I;ve been trying to make a race game but I run into a few problems...
example: http://spikey.dictatuur.nl/race.swf
I am trying to count the laps and I made this script for it (it's all pretty basic, cuz my programming skills are not the best)
I got on my stage 4 mc's (see example) wich are called: intermediate1, intermediate2, intermediate3 (the three black parts on the track) and finish
I thought I'dd count the laps using the following script
Quote:
script attachted to car...
onClipEvent (load) {
// ini
set(lap, 0);
}
onClipEvent (enterFrame) {
// count laps!!
if (hitTest(_parent.intermediate1)) {
set(intermediate, 1);
}
if (intermediate == 1) {
if (hitTest(_parent.intermediate2)) {
set(intermediate, 2);
}
}
if (intermediate == 2) {
if (hitTest(_parent.intermediate3)) {
set(intermediate, 3);
}
}
if (intermediate == 3) {
if (hitTest(_parent.finish)) {
set(lap, lap +1);
}
}
}
but this doesn't seem to work... can anybody tell me howto make this work? I'dd be delighted
thanks all!
View Replies !
View Related
"count" & Timer Question
Can someone help ?..
I read on the flash 5 books "creative web animation"
and at the advanced actionscript corner..,at the while, and for statement, I come across variable name like
"count = 1"
can i check with u guyz if the count is a keyword or juz a variable..?
Coz the book does not says if define the variable properly. and coz confusion in me.
And one more thing is that I wanted to create game that make uses of time to calculate the high score like, if u managed to finish the game fastest then u can win the game..
How can i actually use time to control?..?
iss't the variable "count" got to do with this?..
PLS help!! dessperate need help!....i need to do for my final project!...
thankzz
roland
View Replies !
View Related
Game Timer Help
I have a game I need a timer in and I have an idea how the sequence of events need to happen. But not sure how to set it up.
Here is what I need to happen.
Press a button and the timer starts counting down from 30 to 0 in seconds or as close as flash can get. I also need the time to be displayed in whole numbers.
when the timer reaches 0 then it tells a movie clip to gotoAndPlay a certain frame.
that's it.
How do I set this up? I've done some research and the getTimer(); is often suggested. I even found a way to display the time in whole numbers.
math.round(getTimer()/1000);
But I'm having trouble putting it together. I am using Flash MX
Any help is greatly appreciated.
View Replies !
View Related
Timer For Game
I am creating a chess type game where I need a "chess clock". When one person moves, the other player's clock starts and theirs stops. What is the best way to do this?
Should I use something like a getTime function, or should I make an mc that has code that will count down? Has anyone done this yet?
gamist
View Replies !
View Related
Game Timer
I am having problems with this code. Could someone gloss through it for me. I have attached the file in case it is needed...
I think the problem is in this line:
"if (current elapsed = startCount-current) {"
But am not sure where :s I am trying to learn so would appreciate an explanation
Here is the full code:
onClipEvent (load) {
start = getTimer();
startCount = 90;
}
onClipEvent (enterFrame) {
current = (getTimer()-start)/1000;
if (current elapsed = startCount-current) {
counter = Math.floor(elapsed);;
} else {
_root.gotoAndStop("done");
}
}
View Replies !
View Related
Timer For Game
I looked through the tutorials and all the timers I saw were for either standard clock or a scoreboard.
I am looking for a timer I can use with a game. I am going to create a game where users can arrange movie clips etc. etc. but I want them to be doing it under a timer. When the time is up the ability to move clips stops.
I can control the stopping part I assume no problem. I am just looking for a good clock to integrate.
Idealistically it would have min:Sec:Milsec
Anyone know where i can get one?
Thanks
Dax
View Replies !
View Related
Game Timer
I am creating a game, and want to make a timer that goes for, let's say, 30 seconds. I read the getTimer() function page in Flash help:
this.createTextField("timer_txt", this.getNextHighestDepth(), 0, 0, 100, 22);
function updateTimer():Void {
timer_txt.text = getTimer();
}
var intervalID:Number = setInterval(updateTimer, 100);
When I place this script in my movie, it registers in miliseconds. I want seconds. How do I convert?
Thanks in advance
View Replies !
View Related
Game Timer
This is probably super easy but I was wondering how you add a timer to a game. I am making a simple blackjack game and I want to add a 2 minute countdown timer that ends the game when time expires.
Thanks
Brett
View Replies !
View Related
Game Timer
Hey there
I'm making a game for a client where I need to time how long it takes the user to answer a series of questions correctly.
the timer would start at 00.00.00 and run up till the end of the game.
Can anyone direct me to something like this? I have a lot of design and animation to do for the job and am not a strong programmer so would like a leg up with it.
thanks much for any info!!
Steve
View Replies !
View Related
Game Timer
Im looking for a countdown timer to put in my game. When the timer runs out, i want it to simply go to a specific frame.
I've had a good look around now, and all I can find are usless DATE COUNTDOWN timers. And the only potential timer I found doesnt let me select my own time!
Anyway, im not asking anybody to create one for me or anything. But a little help with key words i should search for, or perhaps you might know of a specific site/tutorial/forum that might help me.
Thanx for your time
Mark
View Replies !
View Related
Game Timer
So I have a game timer that counts down every second. At the moment, I am using a TimerEvent that calls a function every second. I was wondering if there is a more efficient way to do this or is this the best way.
View Replies !
View Related
Adding A Timer To A Game
I am wondering how to add a timer to a game.
I have a game similar to the mosquito game that comes with flash 5.
I have set it so the user has to reach a specified target (e.g. hit 10 mosquitos). I want to put a timer in to see how long it takes for the user to complete the task - then possible display it in the proceeding scene (e.g. "you too 20seconds to hit 10 mossies")
Could someone give me a hint?
Much appreciated
Skek
View Replies !
View Related
Adding A TIMER To My Game...
When a person is finished playing my game, I'd like to have a timer pop up to tell them how long it took them to complete the game...
How do I do this?
Does anyone know where I could find a tutorial, or any help would be appreciated!!
~lafunk~
View Replies !
View Related
Problems With Game Timer
I have a simple timer readout working fine in frame 5 of a game, which I need to be able to stop and start dynamically in two ways. The code for the timer is this:
onClipEvent (load) {
startTimer = getTimer ();
elapsedTime = 0
verybestTimer = "0" +elapsedTime;
}
onClipEvent (enterFrame) {
currentTime = int (getTimer ()/1000);
elapsedTime = Math.round((currentTime - startTime));
verybestTimer = +elapsedTime;
if (verybestTimer <10) {
verybestTimer = "0" +elapsedTime;
}
}
This is all in frame 5, but it is already running when I press a button in frame 1 to get to frame 5, i.e. before the clipEvent(load) has even kicked in!
First I need to stop the timer until I'm in frame 5.
I would also like the timer to stop and display it's stop (pause?) time when the game is over. I don't know if this is possible.
Can anybody help PLEASE???
View Replies !
View Related
Help With Timer To Integrate Into My New Game?
hi all,
ive downloaded this attached timer from this site, but im having problems adding it to my game. i want it to start with a 1:00 countdown when the game begins, which i figured out, but when i try to copy the frames of every layer and pasting it into my game, the time is there, but it never really starts, it just holds still.
the timer is attached so u can have a look. cheers everyone for help..
shroomly.
View Replies !
View Related
Video Game Timer HELP
Hey guys,
Can someone look at the code on the timer in this and maybe tell me what the heck I’m doing wrong? The timer is supposed to countdown from 1 minute and then take you to another frame. I can’t seem to figure out what I did wrong.
Thanks for the help!
View Replies !
View Related
Timer For Non-english Game
hi. i got a script off this website but its not in english...
Im using flash 8
Quote:
function treffer(obj, pkt) {
// wenn flugobjekt von sprungobjekt getroffen
// dann punkte vergeben und wieder nach links positionieren
if (obj.hitTest(_root.objekt.mund)) {
if (obj.kind == "moehre") {
// Punkte hochzählen
_root.punkte = _root.punkte + (pkt*2);
}
if (obj.kind == "traube") {
// Punkte hochzählen
_root.punkte = _root.punkte + pkt;
}
if (obj.kind == "pilz" and _root.punkte <> 0) {
// Punkte hochzählen
_root.punkte =Math.ceil (_root.Punkte/2);
_root.objekt.pilz =true;
}
// Sprungobjekt sagen, dass es wieder nach unten fliegen soll
_root.objekt.spring = 2;
_root.objekt.treffer = true;
// Flugobjekte wieder an ihrer Ausgangsposition positionieren
if (obj.startwo == "links") {
obj._x = -22;
} else {
obj._x = 660;
}
// startvariable vorsichtshalber auf Null setzen, damit das Ding nicht gleich wieder losfliegt
obj.start_this =0;
}
}
function bewege(obj) {
// gesteuert per random wandert das flugobjekt von links nach rechts
if (obj.start_this <> 1) {
obj.start_this = random(15);
obj.wohin = random(15);
if (obj.wohin < 3) {
obj.gotoAndStop(3);
} else if (obj.wohin > 3 and obj.wohin < 8) {
obj.gotoAndStop(2);
} else {
obj.gotoAndStop(1);
}
} else {
if (obj.startwo == "rechts") {
obj._x = obj._x - 11;
}
if (obj.startwo == "links") {
obj._x = obj._x + 11;
}
}
// wenn das flugobjekt über den Rand hinaus ist, soll es wieder zu seinem Ausgangspunkt zurück
if (obj.startwo == "links" and obj._x > 666) {
obj._x = -33;
obj.start_this =2;
}
if (obj.startwo == "rechts" and obj._x < 0) {
obj._x = 660;
obj.start_this =2;
}
}
_root.punkte = 0;
My game came out like this, not understanding the script.
http://media.putfile.com/Peach--Glide-and-Grab
Well. Now the real problem is i want to add on a timer. so that when the timer
runs out you go to the time over screen. can anybody tell me where to put allof this time AS?
View Replies !
View Related
Creating A Game Timer
hey guys! I have already looked for a tut here and other places and i still can't find what im after.
Im creating a game when they start the game a timer begins, when they finish the game, the timer stops and the time is displayed in minutes and seconds it took to complete the game. ( i don't want it to countdown ).
I don't think this is very hard but i cant get it to work. I've tried the get Timer function but i was unsuccessful. Can someone please help me?
Thanks guys.
View Replies !
View Related
Use Timer To Stop Game?
Hi,
I'm working on a space-shooter like video game (I used a tutorial to construct it) but I'm having some real trouble figuring out how to end the game. I'd like for a user to play for a given amount of time (20 seconds, for instance) and then if they haven't been killed to go to the win screen. I've tried to deploy a timer and then included a function that goes to the next scene when the time has elapsed, but that doesn't seem to work at all. I'm not sure what I'm doing wrong here. The .fla can be found HERE.
Here's the actionscript for the whole game. I also created an engine to drive the timer, that code is appended below the main actionscript. Any ideas?
Attach Code
_root.wait = 1;
stop();
var numEnemy = 3;
_root.score = 0;
var fire = false;
//attach pause
_root.attachMovie("pause","pause",1000);
_root.pause._x=400;
_root.pause._y=150;
//make pause invisible
_root.pause._visible = false;
//make pause variable
var paused = false;
//define a listener
var listener = new Object();
listener.onKeyUp = function() {
var code = Key.getCode();
if (code == 80) {
if (paused == false) {
paused = true;
} else {
paused = false;
}
}
};
Key.addListener(listener);
function moveHero(speed) {
//check if key is down
if (Key.isDown(Key.UP)) {
_root.hero._y -= speed;
} else if (Key.isDown(Key.LEFT)) {
_root.hero._x -= speed;
} else if (Key.isDown(Key.DOWN)) {
_root.hero._y += speed;
} else if (Key.isDown(Key.RIGHT)) {
_root.hero._x += speed;
}
if (Key.isDown(Key.SPACE)) {
if (fire == false) {
fireBullets();
}
}
}
var i = 1;
function fireBullets() {
i++;
if (i==5){
i=0;
}
fire = true;
_root.hero.gotoAndPlay(2);
var newname = "bullet"+i;
_root.attachMovie("bullet", newname, i*100);
_root[newname]._y = _root.hero._y-20;
_root[newname]._x = _root.hero._x+80;
_root[newname].onEnterFrame = function() {
if (paused == false) {
var bullet_speed = 12;
this._x += bullet_speed;
if (this._x>700) {
this.removeMovieClip();
}
for (var h = 1; h<=numEnemy; h++) {
if (this.hitTest(_root["enemy"+h])) {
this.removeMovieClip();
_root["enemy"+h].play();
//trace("enemy"+h);
}
}
}
};
}
function Enemys() {
for (j=2; j<=numEnemy; j++) {
var name = "enemy"+j;
_root.enemy1.duplicateMovieClip(name, j);
}
}
Enemys();
_root.onEnterFrame = function() {
if (paused == false) {
_root.pause._visible = false;
moveHero(8);
} else {
_root.pause._visible = true;
}
};
ENGINE CODE GOES HERE:
onClipEvent (enterFrame) {
if (_root.delay) {
if (Math.floor(getTimer()/1000) == _root.lastTime+1) {
_root.delay = false;
}
} else if (Math.floor(getTimer()/1000) == _root.lastTime+_root.wait) {
_root.lastTime = Math.floor(getTimer()/1000);
_root.delay = true;
nextFrame();
}
}
View Replies !
View Related
Timer For Quiz Game
Hi there.
I have designed a flash-based quiz for a training program. they've requested to have a timer that runs throughout the movie to add pressure and action to the game and also to display their time at the end.
Can anyone help me out with this? I've found a few timers but nothing too useful to me.
any help much appreciated!
thanks
Steve
View Replies !
View Related
Game Timer Problems
Hi
I am doing this game in flash 8 proffesionel, but my timer creates a lot of problems. I have been looking everywhere for help, but without any luck.
First I placed a dynamic textfield at frame 1 on the main timeline stage called: mySeconds in the var field.
and placed the value 0 in the textfield on the stage.
Then I wrote this code by opening the actionscript panel at frame 1 on the main timeline:
stop();
function wait() {
mySeconds++;
if (mySeconds == 90) {
gotoAndStop(70);
}
}
myTimer = setInterval(wait, 1000);
Then I place a keyframe on frame 10, 20, 30, 40 50, 60 and 70 where the player is taken to each of these keyframes during the game.
I want the timer to stop on frame 40, 50, 60 and 70 so I put this code on frame 40, 50, 60 and 70:
onEnterFrame = function(stoppo) {
clearInterval(myTimer);
myTimer = setInterval(wait, 1000);
}
the above code stops the timer, so until now the timer works great, BUT when I then write: gotoAndStop(1) after the code on frame 40, 50, 60 and 70
so the movie begin playing frame 1 again, then my timer goes crazy.
Does anybody know how to make a timer who will work in my kind of game?
View Replies !
View Related
|