7 Replies Latest reply on Jun 26, 2006 10:29 PM by kglad

    Asteroid help

      I am creating a sort of flash arcade for a major software assessment, and i am currently trying to create a game based on asteroids, i found a great tutorial at http://www.adobe.com/devnet/flash/articles/asteroids.html
      Anyway, i changed it a little bit so instead of using actionscript to draw my ship and asteroids i used movieclips, the ship works great and fires properly, the problem i am having is with the asteroid, it doesn't break apart like the asteroids are suppose to.
      I use a function to create the asteroid, like in the tutorial, and then used attachMovie
      Can anyone tell me why i can't get my asteroids to break apart?
        • 1. Re: Asteroid help
          kglad Adobe Community Professional & MVP
          have you checked to see if your hitTest() is resolving to true when something hits your asteroid?
          • 2. Re: Asteroid help
            Level 7
            I normally find a ball peen hamner does the job.

            Seriously though, that's kinda 'my car doesn't start - what's wrong?'
            question. You need to describe how you are trying to break apart your
            asteroids, and provide code snippets.

            Remove '_spamkiller_' to mail

            • 3. Re: Asteroid help
              kglad Adobe Community Professional & MVP
              lol, peter. i was taking a more gentle "...let's start from the beginning" approach.
              • 4. Asteroid help
                Thefatman Level 1

                well, for the asteroids it has a function in the tutorial, like this'
                createAsteroid = function() {
                // Let's create an Asteroid
                var rock = this.createEmptyMovieClip("Asteroid", 0);
                rock.lineStyle(3.5, 0x00ff00, 100);
                rock.moveTo(45, -45);
                rock.lineTo(90, -15);
                rock.lineTo(90, 15);
                rock.lineTo(45, 45);
                rock.lineTo(0, 15);
                rock.lineTo(0, -15);
                rock.lineTo(45, -45);

                and i changed it like this
                createAsteroid = function (factor, x, y) {
                var rock = planet;
                After that it goes into some math stuff...which works fine it makes the planet move and what not...the problem is here...i think

                for (b in lasers) {
                var rock = at[ I ];
                var bull = lasers;
                if (md(rock._x, rock._y, bull._x, bull._y)<rock._width/2) {
                at.splice(i, 1);
                if (!_root.gameOver) {
                _root.score += 200;
                if (_root.score<1000) {
                theScore = "000"+_root.score;
                } else if (_root.score>=1000 && _root.score<10000) {
                theScore = "00"+_root.score;
                } else if (_root.score>=10000 && _root.score<100000) {
                theScore = "0"+_root.score;
                } else {
                theScore = _root.score;
                _root.panel.scoreboard.text = "score :: "+theScore;
                if (rock.level<3) {
                at.push(createAsteroid(rock.level, rock._x, rock._y));
                at.push(createAsteroid(rock.level, rock._x, rock._y));
                _root.lasers.splice(b, 1);
                void (bull.removeMovieClip());
                void (rock.removeMovieClip());

                right now i havent changed any of that its exactly as it is in the tutorial which i linked above, but it doesnt work...its probably simple i know but i need help

                by the way...why doesn't my car work?
                • 5. Re: Asteroid help
                  kglad Adobe Community Professional & MVP
                  without seeing what at() is and md() it's not possible to be precise. but it appears your line:

                  var bull = lasers;

                  should be

                  var bull = b;

                  • 6. Re: Asteroid help
                    Thefatman Level 1
                    oh right...theres suppose to be a [ b ] there but i inadvertantly deleted it when it made my text bold

                    anyway...would it be easier for me to just paste the entire code? cause most of its in the tutorial, i've just changed what i have for the asteroid and ship, the ship is now an attach movie and the code for the asteroid is above...
                    • 7. Re: Asteroid help
                      kglad Adobe Community Professional & MVP
                      if that's fixed is at[ i ] your asteroid? if so is there an animation that plays when it's destroyed? is if (md(rock._x, rock._y, bull._x, bull._y)<rock._width/2) {
                      the conditional that tests if your asteroid should be destroyed?