Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > General > Gaming and Game Development

Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 04-29-2008, 07:51 PM   #1
Registered User
Join Date: Mar 2008
Posts: 14
Red face Score - changing frames once it reaches a certain score

I have a game where there is a spaceship shooting at bubbles. The score goes up by 10 each time it hits.

How can I make it so that when the score reaches a certain point, something new happens? (Aka. a gotoandplay so-and-so?)

Here's my code:
var DARTSPEED:Number = 20;
var BUBBLESPEED:Number = 5;
var STAGEWIDTH:Number = 500;
var total:Number = new Number ();

total = 0;

var DARTSTART:Number = dart._y;		// save dart start position

// define the bubbles' behavior
bubble1.onEnterFrame = 
bubble2.onEnterFrame = 
bubble3.onEnterFrame = 
bubble4.onEnterFrame = 
bubble5.onEnterFrame = function() {
   // while bubble is still onstage:
   if (this._x < STAGEWIDTH) {
      this._x += BUBBLESPEED;
      // easier to check here against dart rather than vice versa
      // MUST check if in frame 1 or command will be executed repeatedly
      if (this.hitTest(dart) && this._currentframe==1) {
		 _root.total = _root.total + 10;
   // when bubble goes offstage:
   } else {
      // the following three lines of code add randomness to the balloons' appearance
      // reposition on left, between 0 and 50 pixels to the left of the stage
      this._x = 0-this._width - Math.random()*50;
      // randomly move up or down, up to 20 pixels
      this._y += -20 + Math.random()*40;
      // randomly change size +/- up to 10%
      this._xscale = this._yscale = -10 + this._xscale + Math.random()*20;
      // set back to normal (unexploded) view

// define the shooter behavior
shooter.onPress = function() {
   this.startDrag(false, 0, this._y, STAGEWIDTH-this._width, this._y);
   this.onMouseMove = function() {
      dart._x = this._x + 4;

shooter.onRelease = shooter.onReleaseOutside = function() {
   delete this.onMouseMove;

   dart.onEnterFrame = function() {
      // if the dart is still onstage, move it upwards a defined number of pixels per frame
      if (this._y > 0-dart._height) {
         this._y -= DARTSPEED;
      // if it has gone off the top of the stage, reset it to its original position
	  // and stop the enterFrame to wait for the next release of shooter
      } else {
         this._y = DARTSTART;
         delete this.onEnterFrame;

I'd also like to say thank you to everyone who's helped me thus far. I hope I'm not annoying you!

Last edited by suzierthanyou; 04-29-2008 at 07:55 PM.
suzierthanyou is offline   Reply With Quote

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
displaying variables like a total score StrugglingHard Simple Stuff (Newbies) 4 04-26-2008 05:02 PM
game going to next level when score reaches 20 andythepandy Gaming and Game Development 2 08-18-2007 04:54 PM
LoadVars high score table simon373 Gaming and Game Development 1 07-17-2007 09:11 PM
Quiz score, not working oblivion2010 Other Flash General Questions 5 03-25-2007 06:12 PM
Question Score Weight? Jadeivy ActionScript 2.0 0 06-14-2006 03:26 PM

All times are GMT. The time now is 02:12 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.