A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Having a movie clip "shoot" another object

  1. #1
    Junior Member
    Join Date
    Nov 2000
    Posts
    24
    I'm working on a game right now, and I'm stuck.. I have no idea where to begin. I want to have it so that when you press the spacebar or shift, the movie clip of the character will shoot a bullet.. I have no idea how to make a movie clip of a bullet appear from the x,y coordinates of the character movie clip. If anybody has experience with doing this, could they pleae help me out? I would really appreciate it, Thanks! (I am using Flash 5)

    - Brendan

  2. #2
    Junior Member
    Join Date
    Nov 2000
    Posts
    24

    One more

    One more thing I'd like to clear up, in the last message i think i made it sound like i hadn't gotten anywhere in the game but i already have the movements of all of the characters and objects on the screen, i just need to know how to have the character and badguys able to shoot bullets.

  3. #3
    Senior Member Olorin's Avatar
    Join Date
    Aug 2000
    Posts
    1,151
    Hmmm, let's see... place something like this in the bullet movie clip:

    OnClipEvent(enterframe)
    {
    if (key.isDown(key.SHIFT) && shooting == 0){
    this._x = _root.player._x;
    this._y = _root.player._y;
    shooting = 1;
    }
    if (shooting == 1){
    this._x = this._x + 10;
    }
    if (this._x > 600){
    shooting = 0;
    }


    this code shoots a bullet to the right, and there can only be one bullet on screen at a time. If you want to have several bullets, use duplicateMovieClip, and removeMovieClip to remove the bullet when it is offscreen.

    hope this was helpful,

    Olorin

  4. #4
    Junior Member
    Join Date
    Nov 2000
    Posts
    24

    Smile Yup

    Thanks, that what exactly what i was looking for!

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