I have a question. How did you make your score like that so it reads 00000000 and counts up? I can only get my score to work if it starts as 0 :(
Printable View
I have a question. How did you make your score like that so it reads 00000000 and counts up? I can only get my score to work if it starts as 0 :(
Quote:
Search: Key Word(s): score
Showing results 1 to 25 of 382
Search took 6.47 seconds.
Leave a blank MC offstage with this code in it. Then whenever a player scores points, add those points to _root.scoreHolder instead of directly to the score.Code:onClipEvent (load) {
var one = 0;
var ten = 0;
var hun = 0;
var tho = 0;
var tentho = 0;
var huntho = 0;
}
onClipEvent (enterFrame) {
if (_root.scoreHolder>0) {
_root.scoreHolder--;
if (one+1 != 10) {
one++
} else {
one = 0
if (ten+1 != 10) {
ten++
} else {
ten = 0
if (hun+1 != 10) {
hun++
} else {
hun = 0
if (tentho+1 != 10) {
tentho++
}else {
tentho = 0
huntho++
}
}
}
}
}
_root.score = huntho+""+tentho+""+tho+""+hun+""+ten+""+one;
}
I have searched that before and never found this code about it :confused:
Sorry :( and thanks :)
Is it easy to change the speed in which it goes up, perhaps flicks through tens instead of ones? I've tried but so far I only managed to make it go up to 1000 by mistake :smoov:
[EDIT]: Hmm..when the score gets to 1000, the rolling bar jumps to 10,000. Gonna try and figure out whats wrong :S
Hmm cant work it out, seems to be an inherent problem with it :(
Am using this instead:
Just a shame it means by display doesnt appear as 000000, but at least it goes up properly, and quickly :)Code:onClipEvent (enterFrame) {
if (_root.score<_root.scoreC) {
_root.score += 10;
}
http://img206.imageshack.us/my.php?image=testup8.swf
is this what you mean i made it so it doesnt have much code as well its realy 10000 but i masked out the 1 =)
hope its what you need
heres the source file.
... well masking out is ... an interresting approach ...
or you coud use this:
if you're on AS2 you colud just use the attached StrUtil class, which contains some more string related thingies ... (rename to .as, though) - wow my first open source.Code:/**
* returns a string formated to the total length of Size
* padded with leading zeros
*
* @param value an object (text or number) to be padded
* @param size [optinal] the length of the resulting string
* @return the padded string
*/
function format (value:Object, size:Number):String {
var stringValue:String = String(value);
var strLength = 2;
if (size != null) strLength = size;
while (stringValue.length < strLength) {
stringValue = "0" + stringValue;
}
return stringValue;
}
// usage:
trace( format(1) );
// outputs: 01
trace( format(123, 5) );
// outputs: 00123
nGFX
Quote:
Originally Posted by XareoX
My MX cant load that :(
Sounds like a good idea though I'll come back to it :cool:
Wow, this thread's been hijacked.
"Sounds like a good idea"
Erm, no, it's a really bad way to do it. Use nGFX's code, it's a million times better.
Squize.
ah but its faster if you're displaying in a dynamic text box anyway.
Squize
masking still does the same thing and way easyer
Masking is slower and a clumsy way to do something simple. If you don't want to show the 1 then just use score.toString().substring(1);
Domyboy, spamming is not accepted
self deleted =)
Calm down Xareox.
You obviously didn't read what was above ihoss's post because some guy named 'domyboy' spammed in this thread...He wasnt attacking you.
:o sry =}