A Flash Developer Resource Site

Results 1 to 16 of 16

Thread: [CS3] [AS2] How to make explosions rock the stage

  1. #1
    Senior Member
    Join Date
    Feb 2004
    Posts
    782

    [CS3] [AS2] How to make explosions rock the stage

    Hi,
    I was just wondering in this shooter game on how to make explosions rock the stage like in http://www.newgrounds.com/portal/view/480338 ,when a spaceship runs into you in AS2.
    Flash Ninja Clan - Games and cartoons

  2. #2
    Senior Member Orkahm52's Avatar
    Join Date
    Jan 2006
    Location
    Perth, Australia
    Posts
    335
    Assuming that you've already got a scrolling system set up, all you have to do is set it to "scroll" the screen slightly in each direction very quickly.

    ~Ork.

  3. #3
    Senior Member
    Join Date
    Feb 2004
    Posts
    782
    Well, my game doesn't scroll. Is there a way to do it then?
    Flash Ninja Clan - Games and cartoons

  4. #4
    Senior Member Orkahm52's Avatar
    Join Date
    Jan 2006
    Location
    Perth, Australia
    Posts
    335
    You could loop through all the objects on the stage and move them each in every direction by a little bit. Not entirely sure how your game is set up so I can't offer any useful code unfortunately but inside the loop it would be like so:

    Code:
    var rockAmount:Number = 5;
    object._x += rockAmount;
    object._y -= rockAmount;
    object._x -= rockAmount;
    object._y += rockAmount;
    ~Ork.

  5. #5
    Senior Member
    Join Date
    Feb 2004
    Posts
    782
    Thanks I'll try it.

    If there a way I can do

    Code:
    _root._x+=5;
    _root._x-=5;
    ?
    Flash Ninja Clan - Games and cartoons

  6. #6
    Intermediate Game Dev pseudobot's Avatar
    Join Date
    May 2008
    Location
    New Zealand
    Posts
    561
    ^As far as I know, that won't work. Rather, put everything in teh game in a container movi clip, and then use something like
    PHP Code:
    contanier._x += 5
    to move everything.
    Needs an update...

  7. #7
    Senior Member Orkahm52's Avatar
    Join Date
    Jan 2006
    Location
    Perth, Australia
    Posts
    335
    You can use _root._x and _root.y but it's not a very good idea. Moving _root will move any interfaces as well as the game objects. A much better idea is what pseudobot said with the container movie clip. Though that might take a little while to set up, it's a lot better cause that way you can include some objects and not include others.

    For scrolling games (and also for effects like this), I've found it's a good idea to use a "camera" object that displaces everything. ( a Point would work too but you need to import that class )

    Something along these lines:
    Code:
    var camera:Object = new Object();
    camera.x = 0;
    camera.y = 0;
    
    player._x = player.myX+camera.x;
    player._y = player.myY+camera.y;
    Thats probably a bit too unnecessarily complicated for just this, but it's something to keep in mind for later games.

    ~Ork.

  8. #8
    Senior Member
    Join Date
    Feb 2004
    Posts
    782
    Thanks
    Flash Ninja Clan - Games and cartoons

  9. #9
    Senior Member
    Join Date
    Sep 2008
    Posts
    121
    I just have my entire game area in a MC... that MC will be rockin' when a building is destroyed... simple.

  10. #10
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,926
    Another way around it is to use bitmapData.draw();

    You use draw to copy the entire screen to a bitmap, attach that to a mc and give the mc a low alpha ( Say around 50 ), a blur if you're feeling cheeky, and then just shake that. You then get a good double vision effect and it'll run nice and quickly 'cause you're just moving one movieclip with just one bitmap inside it.

    Squize.

  11. #11
    Senior Member Sietjp's Avatar
    Join Date
    Jan 2005
    Location
    Paris, France
    Posts
    711
    Quote Originally Posted by Squize
    Another way around it is to use bitmapData.draw();

    You use draw to copy the entire screen to a bitmap, attach that to a mc and give the mc a low alpha ( Say around 50 ), a blur if you're feeling cheeky, and then just shake that. You then get a good double vision effect and it'll run nice and quickly 'cause you're just moving one movieclip with just one bitmap inside it.

    Squize.
    Very nice idea, thanks for the tip!

  12. #12
    Senior Member PRadvan's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    261
    Here's a shake effect fla I accidentally created:
    http://www.freeactionscript.com/2009...-shake-effect/

    Accidentally because I was trying to make something else

  13. #13
    Senior Member
    Join Date
    Feb 2004
    Posts
    782
    I just move the main movie clips on the stage, it works quite well. Thanks guys for the tips. You guys are great.
    Flash Ninja Clan - Games and cartoons

  14. #14
    FK founder & general loiterer Flashkit's Avatar
    Join Date
    Feb 2000
    Location
    Sydney
    Posts
    1,149
    Regards Mark Fennell - Flash Kit Founder, general loiterer
    -------------------------------
    I Hate Zombies - iPhone Game | markfennell.com

  15. #15
    Senior Member
    Join Date
    Sep 2004
    Posts
    633
    All you have to do is loop through something like this for a specified period of time:

    _x += -5+random(10);
    _y += -5+random(10);

    It will be different each time and it'll shake whatever you want it to shake.

    Not exactly rocket science.
    Last edited by MikeMD; 02-14-2009 at 04:41 AM.

  16. #16
    Senior Member
    Join Date
    Sep 2006
    Posts
    132
    I was thinking about doing this and thought it would only look affective if container mc were eased through the positions.

    So you don't necessarily need to ease the positions and will still look ok which I shall make note of.
    May 2009 - Working on Thorenzitha RPG - episode 7

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