View Full Version : Help with scores!
ChibiWurld
11-26-2004, 02:34 AM
is there any way to make it where like if someone gets a certain amount of points something happens?
ex. My Character scores 150,000 points and then goes to a new level
anyway to do something like that?
Thanks in advance
arkhan
11-26-2004, 05:48 AM
if(score >= the number you want){
something hapends
}
it says that, if the variable score is bigger or equal to the number you want, somenthing will hapend
ChibiWurld
11-26-2004, 11:54 AM
well its not working..
is there anyway to make it where if the score is higher or equal than a designated number that it goes to a different scene?
I keep trying to work with it... maybe iv got the code wrong =/
The Brown Cow
11-26-2004, 12:32 PM
_root.onEnterFrame = function() {
if (score >= 150000) {
_root.gotoAndStop("name_of_desired_frame");
delete _root.onEnterFrame;
}
}
Every frame we check to see if the score is greater than 150,000. If it is, we go to the desired frame label and stop checking the score.
ChibiWurld
11-26-2004, 01:09 PM
well theres a problem. the game is only one frame long.
to see what i mean go here http://chibiwurld.homestead.com
The Brown Cow
11-26-2004, 01:14 PM
Okay.
_root.onEnterFrame = function() {
Â# Â# Â#if (score >= 150000) {
Â# Â# Â# Â# Â#// Code for whatever you want to have happen goes here
Â# Â# Â# Â# Â#delete _root.onEnterFrame;
Â# Â# Â#}
}
ChibiWurld
11-26-2004, 04:01 PM
hmm im not sure where to put it in the game. heres the scripts i have in my game
Character---Insance(spaceship)
------------------------------
onClipEvent(load){
moveSpeed=10;
_root.laser._visible=false;
laserCounter=1;
scrollx=_root.mainGround.ground._width/3;
scrollStart=false;
maxLasers=4;
depthCounter=1;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.CONTROL) and (laserCounter<=maxLasers)) {
laserCounter++;
_root.laser.duplicateMovieClip( "laser"+depthCounter, depthCounter );
_root["laser"+depthCounter]._visible=true;
depthCounter++;
if (depthCounter>maxLasers){
depthCounter=1;
}
}
if (Key.isDown(Key.RIGHT)) {
if (this._x<scrollx){
this._x+=moveSpeed;
} else {
scrollStart=true;
}
} else if (Key.isDown(Key.LEFT)) {
this._x-=moveSpeed;
}
if (Key.isDown(Key.DOWN)) {
this._y+=moveSpeed;
} else if (Key.isDown(Key.UP)) {
this._y-=moveSpeed;
}
}
onClipEvent (keyUp) {
if (Key.getCode() == Key.RIGHT) {
scrollStart=false;
}
}
-----------------------------
Bullet---Instance(laser)
-----------------------------
onClipEvent (load) {
laserMoveSpeed=20;
this._x=_root.spaceship._x+90;
this._y=_root.spaceship._y;
}
onClipEvent (enterFrame) {
if (this._name<>"laser"){
this._x+=laserMoveSpeed;
if (this._x>600){
_root.spaceship.laserCounter--;
this.removeMovieClip();
}
for (i=1; i<=_root.numEnemy; i++){
if (this.hitTest( _root["enemy"+i])){
_root.score+=100;
_root["enemy"+i].gotoAndPlay( 2 );
}
}
}
}
---------------------------
Enemy--Instance(enemy)
---------------------------
onClipEvent (load) {
function reset(){
this._x=600;
this._y=random(200)+100;
enemySpeed=random(4)+1;
this.gotoAndStop(1);
}
reset();
}
onClipEvent (enterFrame) {
if (_root.spaceship.scrollStart){
this._x-=enemySpeed+_root.mainGround.groundSpeed;
} else {
this._x-=enemySpeed;
}
if (this._x<-10) {
reset();
}
if (this.hitTest( _root.spaceship ) ){
_root.gotoAndStop ( "gameOver" );
}
}
------------
Frame one on a layer called control
numEnemy=5;
for (i=2; i<=numEnemy; i++){
enemy1.duplicateMovieClip( "enemy"+i, i+100 );
}
score=0;
Please help me and sorry for the long post
The Brown Cow
11-26-2004, 04:26 PM
You can put my code on frame one of the main timeline, or you can adapt it to fit into one of the other onEnterFrame handlers, if you feel clever.
theneedforsex
12-08-2004, 07:48 AM
This here is simple, but how about saying:
if (score>=150000) {
level = (desired level);
}
if thats what you want to happen?
This script can go, in a button or a movieclip.. Anywhere..
Just put it in a handler...?
But its probably to simple?
bobmasedo
12-08-2004, 09:07 AM
i recreated this and put this in the spaceship after
onClipEvent (enterFrame) {
if (_root.score >= 150000){
_root.dowhatever
}
and in the enemy I made it:
if (this._x<-10) {
_root.score += 150000
reset();
}
and it worked
vBulletin® v3.7.3, Copyright ©2000-2009, Jelsoft Enterprises Ltd.