Page 1 of 2 12 LastLast
Results 1 to 15 of 29

Thread: Random vertically scrolling stars

  1. #1

    Random vertically scrolling stars

    How to make random vertically scrolling stars to my space fighter game?

  2. #2
    Well, are you doing it by duplicating an mc or a bitmap or many stars? can u give a screenshot of what you want?

  3. #3
    Quote Originally Posted by Dr Warm
    Well, are you doing it by duplicating an mc or a bitmap or many stars? can u give a screenshot of what you want?
    I mean stars like in this game http://www.miniclip.com/warrior.htm

  4. #4
    icio's Avatar
    3,811
    posts
    looks better in lowercase
    make a new movieclip with the star in it, and set it's linkage to export for actionscript, with a linkage id: "star".

    then put this code root
    Code:
    speed = 10;
    star = function() {
    this._y = this._height * -1;
    this._x = Math.random() * Stage.width;
    }
    Object.registerClass("star", star);
    star.prototype.onEnterFrame = function() {
    this._y += speed;
    //
    if (this._y > Stage.height) {
    removeMovieClip(this);
    }
    }
    //the code to add stars:
    this.onEnterFrame = function() {
    starCount++;
    _root.attachMovieClip("star", "star_"+starCount, starCount);
    }
    i think this should work. i've not got flash installed atm so i can't check it. unless there's any bugs in it, it will.

    hope this helps
    "60% of the time it works... every time." -- Paul Rudd as Brian Fantana.

  5. #5
    Umm it didnt work.. So?
    First i need to inser new movie clip? Do I name it star and linkage id star export for actionscript? then i draw the star into the movie clip? Then i need to place the star to the stage and enter actionscript?

    and I need bit more help with this game..
    If enemy hits the hero its shield goes to "damage" frame?

    Woohoo! I got the shield damage to work by myself!

  6. #6
    hey cyberalthete i can never see what u post for some reason, it looks like this to me:
    then put this code root


    i think this should work. i've not got flash installed atm so i can't check it. unless there's any bugs in it, it will.
    where i'm guessing they'res supposed to be code after the root, not a gap? is they're something wrong with my browser?

    Then i need to place the star to the stage and enter actionscript?
    no, u just leave it in the library, if you give it a linkage name, flash will be able to find it with attachMovie

  7. #7
    I cant get it working.. Could you send me .fla?

    And i need some help with secondary fire.

  8. #8
    sorry i can't get to flash atm but i had this on disk of a fishy game i started making, the first frame (menu) has bubble's coming up if you wait long enuf, the code for that is on the first frame, not in the timeline but on the right side of the stage (from memory)

    hope it helps
    Attached Files Attached Files

  9. #9
    Quote Originally Posted by Dr Warm
    sorry i can't get to flash atm but i had this on disk of a fishy game i started making, the first frame (menu) has bubble's coming up if you wait long enuf, the code for that is on the first frame, not in the timeline but on the right side of the stage (from memory)

    hope it helps
    Ok i got it working somehow.. but how do i make it so that the stars move down without mouse. Hope you get the point

  10. #10
    icio's Avatar
    3,811
    posts
    looks better in lowercase
    well, i used attachMovieClip instead of attachMovie.. Woops. !! try fixing that:
    Code:
    speed = 10; 
    star = function() { 
    this._y = this._height * -1; 
    this._x = Math.random() * Stage.width;
    }
    Object.registerClass("star", star);
    star.prototype.onEnterFrame = function() {
    this._y += speed;
    //
    if (this._y > Stage.height) {
    removeMovieClip(this);
    }
    }
    //the code to add stars:
    this.onEnterFrame = function() {
    starCount++;
    _root.attachMovie("star", "star_"+starCount, starCount);
    }
    hope that helps
    "60% of the time it works... every time." -- Paul Rudd as Brian Fantana.

  11. #11
    So.. Do i need to but that script into the frames actions? And do i need to check "export in first frame"?


    By the way heres the swf of my game..
    Attached Files Attached Files

  12. #12
    icio's Avatar
    3,811
    posts
    looks better in lowercase
    why don't you just use the same method that you have used to do the bullets?
    except make them move down, and make their _x property random.

    but to answer your question, put that code in the frame with the ship in it, of the main timeline.for export in first frame, try it with and without, with if it's default.
    "60% of the time it works... every time." -- Paul Rudd as Brian Fantana.

  13. #13
    Quote Originally Posted by cyberathlete
    why don't you just use the same method that you have used to do the bullets?
    except make them move down, and make their _x property random.

    but to answer your question, put that code in the frame with the ship in it, of the main timeline.for export in first frame, try it with and without, with if it's default.
    Yay it works! Thanks!

  14. #14
    Wtf?! This is weird.. If i but the star script on the layer where the hero is the stars will work but if health is zero it goes to gameover frame script wont work..

    This is my the script what i have in the hero layer:
    PHP Code:
     _root.onEnterFrame = function() {
    if (
    score>11900) {
    _root.gotoAndPlay("mission");
    } else {
    trace(score);
    }
    if (
    health<10) {
    gotoAndStop("gameover");
    } else {
    trace(health);
    }
    }
    _root.score 0;
    _root.health 100;
    stop();
    speed 10;
    star = function() {
            
    this._y this._height * -1;
            
    this._x Math.random() * Stage.width;
    }
    Object.registerClass("star"star);
    star.prototype.onEnterFrame = function() {
            
    this._y += speed;
            
    //
            
    if (this._y Stage.height) {
                    
    removeMovieClip(this);
            }
    }
    //the code to add stars:
    this.onEnterFrame = function() {
            
    starCount++;
            
    _root.attachMovie("star""star_"+starCountstarCount);


  15. #15
    come on help me out here :S

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012