David Danielsson sent in a tutorial. It’s so you can make something shoot left and right, like in a sidescrolling shooter. You can add a bit of code to it to make it shoot in 4 directions easily though. Here it is:

(Either JavaScript is not active or you are using an old version of Adobe Flash Player. Please install the newest Flash Player.)

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • description
  • Furl
  • Slashdot
  • StumbleUpon
  • Technorati

29 Responses to “Creating a Multi-Directional Shooter”

  1. David Says:

    Thanks for uploading and editing. You made it alot better.

  2. awesty Says:

    No worries. I didn’t change any of the tutorial, I just made the look of it suit the blog. :)

  3. David Says:

    I just noticed a bug in the full code…
    _root["Bullet"+i]._x = Ship._x+3;
    and
    _root["Bullett"+i]._x = Ship._x-20;

  4. awesty Says:

    Well it should really be:
    _root["Bullet"+i]._x = Ship._x + Ship._width / 2;

    But it won’t really make that much of a difference.

  5. David Says:

    Nah the reg. point is in the middle. So the ship._x and ship._y is good enough

  6. Mike Says:

    Hey guys, I know this is off topic, but… I’m not sure how you would put this code in a frame, not a movie clip:

    if (root._score <=0) {
    gotoAndPlay(6);
    }
    ————————————————-
    Yeah, I know I’m stupid and I know I’m bad at coding but if someone could show me how to put this in a frame that would be great. Or even if they could change it if they know what I’m talking about :| , but whatever.

    P.S. I’m working in AS2

  7. awesty Says:

    You would put it inside the onEnterFrame funtion. It would look something like:

    onEnterFrame = function(){
    …other code here…

    if (root._score <=0) {
    gotoAndPlay(6);
    }
    }

  8. someone Says:

    hey i know this is off topic but i dont know where else to put it (seeing as the old site is dead). Iv’e been trying to create a platformer game in which there are also enemies, ive tried combining some of the code from 2 of your old tutorials but i cant get him to jump :( anyway this is the code on the main “man” MC
    onClipEvent(load){
    fight = false;
    }
    onClipEvent(enterFrame){
    if(fight == false){
    if(Key.isDown(Key.LEFT) && fight != true){
    this._x -= 12;
    this._xscale = -100;
    this.gotoAndStop(3);
    }else if(Key.isDown(Key.RIGHT) && fight != true){
    this._x += 12;
    this._xscale = 100;
    this.gotoAndStop(3);
    }else{
    this.gotoAndStop(2);
    }
    }
    if(Key.isDown(Key.SPACE)){
    this.gotoAndStop(4);
    fight = true;
    }
    if(this._currentframe == 1){
    fight = false;
    }
    }
    onClipEvent(load){
    var jump:Number = 0;
    var jumping:Boolean = false;
    var falling:Boolean = false;
    var g:Number = 10;
    }
    onClipEvent(enterFrame){
    if(jumping == true || falling == true){
    this._y -= jump;
    }
    if(jumping == false){
    if(!falling){
    jump = 0;
    }
    if(Key.isDown(Key.UP)){
    jump = 15;
    jumping = true
    }

    }
    if(jumping == true){
    jump -= 1;
    }
    if(jump <= -10){
    jump = -10;
    }
    for(i=0;i<g;i++){
    if(jumping == true && this.hitTest(_root["ground"+i])){
    jumping = false;
    }
    }
    for(i=0;i<g;i++){
    if(!jumping && !this.hitTest(_root["ground"+i]) && !falling){
    falling = true;
    this._y -= 1;
    }
    }
    if(falling == true){
    for(i=0;i<g;i++){
    if(this.hitTest(_root["ground"+i])){
    falling = false;
    }
    }
    jump -= 1;
    }
    }
    I know it is probably useless but its the best i could do, and if you do decide to help me and you need more info email me at Phill.rulerofyou@gmail.com

  9. Brian Says:

    Okay I know this is not in the right tutorial, but I couldn’t find any tutorial about this
    anywhere,and your old site died,
    and I need your help.

    How do you make a bar go up when you touch something? Not down.

  10. Brian Says:

    oh nevermind, I solved it

  11. Brian Says:

    Ok this is off topic but…

    how do I make the character
    move up with W
    down with S
    Left with A
    and
    Right with D

    Ignore the posts I made above.

  12. Dan Says:

    i need help with that too. something about 65=a, etc?

  13. dave Says:

    When i do this, it only shoots right
    and when i press another button, it doesnt shoot at all?

  14. Republic Polytechnic Says:

    You’ve written a very well-written blog post.
    If it’s fine with you, I would like to seek permission to use your article as it relates to my problem. I will be glad to negotiate to pay you or hire you for this.

    With Regards from
    Republic Polytechnic

  15. e cigarette refill Says:

    electronic cigarettes are the greatest thing to ever hit the market for smokers, I wasn’t even trying to quit regular cigarrettes. I intended to use the electronic cigarette to smoke more places and more often. within a week I could no longer stand cigarettes.

  16. Lyda Showden Says:

    I like this blog so much, saved to fav.

  17. Israel Joris Says:

    Thank you for taking time to write this post. It’s been very valuable. It couldn’t have come at a greater time for me!

  18. ipad au Says:

    You realize in which press button from the elevator that has a fireman’s hat on there? Ends up that’s DEFINITELY NOT the key anyone press in order to get some sort of fireman’s cap.

  19. hotels near wembley stadium Says:

    Its like you read my mind! You seem to know so a lot about this, like you wrote the book in it or some thing. I feel that you simply could do with some pics to drive the message house a bit, but other than that, this is great weblog. A great read. Ill certainly be back.

  20. gegiptKit Says:

    Rokit has a wide range of coats, denims, Hawaiian and Cuban shirts at the same time as scarves, tracksuits and theiraccessories make the outfit complete. Belts, jewelry, sunglasses and some very extraordinary watches supportcolour you want, and that it’s uncomfortable and not ideal for if you want to use it. It makes perceptiontraditional bars.The New Town also has its fair share of pubs and bars with most of them lining Rose Streetgoes.They apparently used the capital amount to buy a thousand meters of white cotton that they then made brand High Street stores, spouse and children run businesses, luxurious designer shops and speciality shops to chose from.paying off a mortgage – most peoples largest debt – can often take up to 20 years, all too often consumersAdventure and Outdoor SportsDublin has a wonderful and diverse landscape that offers an excellent platformfrom 11am to 12 midnight and on Sundays from 12.30 to midnight. Nighclubs stay open into the early hours andand two twenty year old shopping daughters. When I came to write this post, I therefore went to them for

  21. Euro 2012 Betting Guide Says:

    Keep up the good work, I read few content on this web site and I believe that your website is really interesting and contains bands of wonderful info.

  22. lyroiltdiop Says:

    almost certainly quite possibly the most handy to youat any time you likewise as your husband too as your youthful children go Canada Goose Jakke taught concerning the means in the productionIts main production is winter season clothingIn the workshop of Canada

  23. ottoman Says:

    Our Furniture Store has one of a kind living room, bedroom, dining room, and patio furniture. For those who cannot get a hold of modern furniture in their state, you should definitely consider us to be your provider. People from the Midwest, this means you! We would like to invite you to browse our huge selection of modern sofas, platform beds, contemporary dining sets, and cool looking patio furniture. Our furniture stores are located in Los Angeles, but we ship nationwide to big cities like Dallas Atlanta New York New Jersey Chicago Miami and Las Vegas. Some of our furniture is eligible for free shipping nationwide. Please do not hesitate to call LA Furniture Store and speak to one of our friendly customer service representatives who are standing by.
    good story, all laid out on the shelves

  24. Party Says:

    I’ve read some just right stuff here. Certainly worth bookmarking for revisiting. I surprise how much attempt you set to create the sort of great informative site.

  25. need home loans Says:

    Thank you so much pertaining to giving me an update on this topic on your website. Please be aware that if a completely new post appears or if any alterations occur with the current posting, I would be interested in reading more and knowing how to make good using of those techniques you discuss. Thanks for your time and consideration of other individuals by making this web site available.

  26. Charley Garasha Says:

    Can I simply just say what a comfort to uncover an individual who really knows what they are talking about online. You certainly understand how to bring a problem to light and make it important. A lot more people have to look at this and understand this side of your story. I can’t believe you aren’t more popular because you surely possess the gift.

  27. Toney Framptonnon Says:

    ,

  28. Keiko Mercy Says:

    hello!,I like your writing so so much! share we be in contact more about your post on AOL? I need an expert in this area to unravel my problem. Maybe that is you! Taking a look ahead to peer you.

  29. chelcie wimmer Says:

    Very good article! We will be linking to this particularly great article on our website. Keep up the great writing.

Leave a Reply