A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Bullet holes for first person shooter

  1. #1
    Junior Member
    Join Date
    May 2004
    Location
    Springfield, OR
    Posts
    21

    take MC out of liberary and place where clicked

    I need help doing this: i have a movie clip, and when it is clicked on, I want flash to take a certain movie clip out of the liberary and place it where the mouse was clicked. i want it to be part of the MC that was clicked on, so when i tween it away the placed movie clip goes with it. i think i would use attachMovieclip or something like that, so please tell me how to use it.

    if what i said above doesn't make sense, there is a wall MC and when clicked i want a bullet MC to be placed on top of that so it looks like you shot the wall.

  2. #2
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    This script assumes that the bullet-hole movie in your library is called 'bullet_mc' (the linkage-export name, that is). It also assumes that layer 1 of your wall movie is available for use. If not, use a higher layer number than 1.

    code:

    wall.onPress = function()
    {
    var mc = this.attachMovie('bullet_mc', 'bullet_mc', 1);
    mc._x = this._xmouse;
    mc._y = this._ymouse;
    }



    Shorter version, in which properties are specified in the last argument to the attachMovie function:

    code:

    wall.onPress = function()
    {
    var mc = this.attachMovie('bullet_mc', 'bullet_mc', 1, {_x:this._xmouse,_y:this._ymouse});
    }


  3. #3
    Junior Member
    Join Date
    May 2004
    Location
    Springfield, OR
    Posts
    21

    Bullet holes for first person shooter

    Here's the deal. ive posted several times about this but i don't get what im looking for. I have a first person shooter. there are walls and these walls are movie clips with only one frame. when clicked on, i want this to happen: i want a movie clip of a bullet hole to be taken out of the liberary and ploped onto the wall where it was clicked on. But i don't want it to be placed on the .root, but in the wall mc itself, so when the wall tweens away the holes go with it.

    i just want you to tell me where to put the action script and what it is, and how to set it up and stuff. thanx

  4. #4
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    I merged this with your last thread on this subject.

    My example from the last thread does indeed attach the bullet hole to the wall using attachMovie.

    Maybe I can help...

    Would you explain in more detail what you didn't understand about this last example? If you attempted to use it, and it didn't work, post your .fla, so we can see where the problem is.

    Thanks,

    - Jim
    Last edited by jbum; 05-29-2004 at 02:51 AM.

  5. #5
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    Okay, responding to a private message, here's a sample .fla that implements something close to the above script.

    Here are the steps I took to create this movie.

    1. Drew the wall.
    2. Converted it to a symbol.
    3. Named the wall movie on the stage "wall"

    4. Drew a bullet hole.
    5. Converted it to a symbol.
    6. Edited the symbol. Made sure the crosshairs were centered so the center of the bullet corresponds to mouse.

    7. Opened the library, used 'linkage...' command to give the bullet-hole the export name of "bullet_mc".

    8. Remove the bullet-hole from the stage (leaving version for export in the library).

    9. Added this script to frame one of movie:

    code:

    wall.onPress = function()
    {
    var mc = this.attachMovie('bullet_mc', 'bullet_mc', 1);
    mc._x = this._xmouse;
    mc._y = this._ymouse;
    }



    At this point I tested it, and discovered a bug - I was using the same layer number for each bullet, causing the last bullet to disappear when a new bullet was added.

    Here's the fix for that problem. It uses a unique layer number for each bullet.

    code:

    kNbrBullets = 0;

    wall.onPress = function()
    {
    var mc = this.attachMovie('bullet_mc', 'bullet_mc', ++kNbrBullets);
    mc._x = this._xmouse;
    mc._y = this._ymouse;
    }



    - Jim
    Attached Files Attached Files

  6. #6
    Junior Member
    Join Date
    May 2004
    Location
    Springfield, OR
    Posts
    21

    thanks

    thank you so much for the help. now i can get started on the game i wanted to make .

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