A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Fully automatic weapon for game?

  1. #1
    village idiot BlackCow237's Avatar
    Join Date
    Aug 2004
    Location
    Earth
    Posts
    192

    Fully automatic weapon for game?

    I know how to make a basic shoot em up game with the aimer and the people and all that good crap but I want to make one with automatic weapons. So when I click down I need an animation (for the gun) to loop and I need it to keep doing damage as its shooting. Anyone kno of a tutoiral or anything to help me with this?

    This is our world now, the world of the electron and the switch. We exist without nationality, skin color, or religious bias.

  2. #2
    Senior Member
    Join Date
    Aug 2004
    Location
    San Diego, California
    Posts
    421
    For the animation, you could animate a gun that constantly recoils and shakes using motion tweening or something like that.

    As for the scripting, you could write a function that checks if the the user has to mouse button pressed.

    So maybe a mouse function like this?:

    mouseObject = new Object();
    mouseObject.onMouseDown = function () {
    _root.userIsShooting = true;
    }
    mouseObject.onMouseUp = function () {
    _root.userIsShooting = false;
    }
    Mouse.addListener(mouseObject);

    Then write an onEnterFrame to check if the user is clicking, if it is then deal damage:

    //declare the variables first
    userIsShooting = false;
    damage = 10;
    onEnterFrame = function () {
    if (userIsShooting) {
    damage --;
    }
    }

  3. #3
    Style Through Simplicity alillm's Avatar
    Join Date
    Mar 2004
    Location
    Wales
    Posts
    1,988
    You can use
    Code:
    if (Key.isDown(1)) {
    }
    to check to see if the left mouse button is down... you could then use a rollOver, or custom cursor hitTest to check for collision with the enemys.
    Code:
    on (rollOver) {
    hitting = true
    }
    on (rollOut) {
    hitting = false
    }
    onClipEvent (enterFrame) {
    if (Key.isDown(1) && hitting == true) {
    //hurt me
    }
    Not the best way ever, but it will do

    Ali

  4. #4
    better than chuck norris
    Join Date
    Jun 2004
    Location
    West Coast of Michigan
    Posts
    667
    if (key.isdown(1)) works great. then you can have a time variable that adds and if it's greater than a certain amount it shoots if it's otherwise too fast.

  5. #5
    village idiot BlackCow237's Avatar
    Join Date
    Aug 2004
    Location
    Earth
    Posts
    192
    Quote Originally Posted by andross_88
    For the animation, you could animate a gun that constantly recoils and shakes using motion tweening or something like that.

    As for the scripting, you could write a function that checks if the the user has to mouse button pressed.

    So maybe a mouse function like this?:

    mouseObject = new Object();
    mouseObject.onMouseDown = function () {
    _root.userIsShooting = true;
    }
    mouseObject.onMouseUp = function () {
    _root.userIsShooting = false;
    }
    Mouse.addListener(mouseObject);

    Then write an onEnterFrame to check if the user is clicking, if it is then deal damage:

    //declare the variables first
    userIsShooting = false;
    damage = 10;
    onEnterFrame = function () {
    if (userIsShooting) {
    damage --;
    }
    }
    Im a bit confused how I would add this to the movie though. When the mouse is down I need it to loop an animation.
    This is our world now, the world of the electron and the switch. We exist without nationality, skin color, or religious bias.

  6. #6
    Style Through Simplicity alillm's Avatar
    Join Date
    Mar 2004
    Location
    Wales
    Posts
    1,988
    Why not use my code then? Theres nothing wrong with andross' code, but if you don't understand it why not use a simpler option??

    Ali

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