A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: help with turrets on space shooter

  1. #1
    Junior Member
    Join Date
    Jul 2005

    help with turrets on space shooter


    I am making a flash side scrolling space shooter. I am having a coding problem on the boss. I have a movie clip with the boss in it, then in that movie clip is each piece of the bossship as a movieclip, and in the pieces with turrets attached they are in movieclips on the piece. The turrets are supposed to follow where your ship goes. It works to an extent but as the main movie clip moves around the aiming of direction gets off. Any solution to make this work right? Also I been trying to figure out how to make him shoot from the turrets and have the bullets go in a straight path instead of along with the bossclip.

    Here is the files:
    Arrows to move....shift is fire

    full game so far:
    starting at boss so you can see the problem:
    FLA file starting at boss:

    Here is the code on the turret that is within movieclips: boss/bossbottom movieclips:

    X = this._x + 250
    Y = this._y + 135
    Xm = _root.ship._x;
    Ym = _root.ship._y;

    Xdiff = X - Xm;
    Ydiff = Y - Ym;

    radAngle = Math.atan2(Ydiff , Xdiff);

    this._rotation = radAngle*360/(2*Math.PI);

    Any help is appreciated thanks!!


  2. #2
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    You can use localToGlobal function to find coordinates of turrets in the _root level or you can add it parent to the coordinates:

    X = this._x + _parent._x
    Y = this._y + _parent._y

    or if they are 2 movie clips deep

    X = this._x + _parent._x + _parent._parent._x
    Y = this._y + _parent._y + _parent._parent._y

    To make bullets fly in straight path you need to attach them in _root level and not inside boss movie clip.

  3. #3
    Junior Member
    Join Date
    Jul 2005


    thanks tonypa, I will try this as soon as I can

    appreciate it

  4. #4
    Junior Member
    Join Date
    Jul 2005
    I can duplicate a shot movieclip and make it appear near the correct location, but not at the end of the turrets. When the turrets follow, the X and Y changes, how would I determine where to move the bullets at so they spawn where they should when I duplicate them? Also, how do I determine the angle of the turrets and make the bullet move straight out the way it is moving? Not sure how to get how much they should move in Y and X to look right
    Last edited by tcooley2003; 08-26-2005 at 05:00 PM.

  5. #5
    Junior Member
    Join Date
    Jul 2005
    Anyone have any idea how to do this? Still looking for a solution. I have messed with the code but nothing has came even close to how it should be.


  6. #6
    AquaCorpse saves the day again
    Join Date
    Jun 2005
    that's a cool boss by the way nice work
    aqua corpse he's a really cool guy...

  7. #7
    Junior Member
    Join Date
    Jul 2005
    the game is farther along now than when this was posted, once I can get these turrets working, if I can get them working that is, I will post a complete version of the game to mess with. It has came a long way

  8. #8
    my x booty it is that BIG
    Join Date
    Jun 2004
    New York
    make it shoot with A or Z or SPACE instead shift is not good and by the way look in
    www.gotoandplay.it i think there is a tutorial about wat u are asking in there
    edit: i noticed a lil tiny bug when you shooting and going up the ship goes to the shootin animation make it looks buggy
    Last edited by mixedtrigeno; 08-26-2005 at 07:49 PM.
    Project||[GAME]-on hold for now

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