A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Shooting Game Missile Flaw

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    23

    Shooting Game Missile Flaw

    I'm making a Space Invaders-type game. Y'know? Arrow keys to fly Space to shoot? Well, shooting isn't working so well. I have two .as files: Ship.as which controls the ship's ActionScript, and Missile.as which is supposed to control the missile. When I hit load it up I get the error: The class or interface 'Missile' could not be loaded.

  2. #2
    Junior Member
    Join Date
    May 2010
    Posts
    23

    Shooting Game Missile Flaw

    I'm making a Space Invaders-type game. Y'know? Arrow keys to fly Space to shoot? Well, shooting isn't working so well. I have two .as files: Ship.as which controls the ship's ActionScript, and Missile.as which is supposed to control the missile. When I hit load it up I get the error: The class or interface 'Missile' could not be loaded. When I press spacebar, the missile appears and just sits there on the stage doing nothing.

    Here's the missile ActionScript:


    Actionscript Code:
    class Missile extends MovieClip
    {
        var speed;
       
        function onLoad()
        {
            speed = 20;
        }
       
        function.onEnterFrame()
        {
            _x += speed;
            if(_x > 600)
            {
                this.removeMovieClip();
            }
        }
    }

    ...and here's the ship ActionScript:

    Actionscript Code:
    class Ship extends MovieClip
    {
        var velocity;
        var shootLimiter;
       
        function onLoad()
        {
            velocity = 10;
            shootLimiter = 0;
        }
       
        function onEnterFrame()
        {
            shootLimiter += 1;
           
            if( Key.isDown(Key.LEFT) ){ _x -= velocity; }
           
            if( Key.isDown(Key.RIGHT) ){ _x += velocity; }
           
            if(Key.isDown(Key.UP) ){ _y -= velocity; }
           
            if( Key.isDown(Key.DOWN) ){ _y += velocity; }
           
            if( Key.isDown(Key.SPACE) && shootLimiter > 8)
            {
                shootLimiter = 0;
                var missile = _root.attachMovie("Missile","Missile" + _root.getNextHighestDepth(), _root.getNextHighestDepth());
                missile._x = _x + 50;
                missile._y = _y + 2;
            }
        }
    }

    Please help, I've been trying to figure this out for days. >_<;

  3. #3
    Junior Member
    Join Date
    May 2010
    Posts
    23
    PROBLEM SOLVED! I had to put all of the files in the same folder in order for them to be located. And here I thought it was an ActionScript issue.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center