User Tag List

Results 1 to 7 of 7

Thread: Best way to do a screen shake?

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,190
    Mentioned
    17 Post(s)
    Tagged
    0 Thread(s)

    Best way to do a screen shake?

    I have ahd a long standing problem with my game's screenshake. I have been offsetting the game layers by a random few pixels every frame. This works great for everything except my player. Since the layer positions update at the end of the frame, it appears the player is constantly lagging behind the layer shift, which results in their fall animation playing when the layer moves down in Y. It also doesn't allow me to jump cleanly, since the fall state disables the ability to jump. An int he worst cases, the game will actually crash, presumably because the fastloop movement for the jumping is getting stuck on some positional offset.

    Can anyone offer a solid solution for screen shaking that is simply shaking the camera position without needing to offset the layers?

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)

    Join Date
    Jun 2006
    Location
    Killeen, TEXAS
    Posts
    1,020
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    set a few variables for your shake; camera current X,T; shake timer & shake amount;
    reserve a flag for shaking;
    if your camera shake flag is ON;
    set your camera position to the current X,y position + (random +/- shake amount) on both axis (or either depending on your effect); add the timer; when the timer is done, reset values, and turn off flag

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,190
    Mentioned
    17 Post(s)
    Tagged
    0 Thread(s)
    Haha. Thanks Django. I actually have that whole setup, but was applying the x/y offsets to layer positions. I guess the best alternative is to just center the frame on (Frame width*0.5)+xOffset and (Frame Height*0.5)+yOffset ? I don't actually use a camera object, since my game has limited scrolling.

  4. #4
    Clicker Fusion 2.5 Developer

    Join Date
    Feb 2014
    Posts
    866
    Mentioned
    10 Post(s)
    Tagged
    1 Thread(s)
    yes, this can be a real pain in the backside to do as the collision lag bug comes into effect. only way i can think is to stick a qualifier on everything u want to shake, create an active object at 0,0, then shake the active & make all the qualifier objects mirror the shaking active, but dont add the qualifier to the collision detection actives, so the detect correctly. altho this means u hav to hav a seperate collision mask object for every single collidible object

  5. #5
    Clicker Fusion 2.5
    casleziro's Avatar
    Join Date
    Mar 2013
    Location
    United States
    Posts
    563
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Personally, I leave an 8 pixel border around my actual level, then constrain the scrolling within this border, adding the shake offset at the end. This will work with any size level (even a single room, if you are "scrolling" by moving the actual layers since it will just focus on the center of the room + shake values). The black border is just for the example; you can of course add whatever graphics to this outside space so things look nicer.

    shake with border.mfa

    Here, the level is 960x480, with a 320x240 window, and 8 pixel border. Use arrow keys to move and press Space to shake.

  6. #6
    Clicker Fusion 2.5 Developer

    Join Date
    Feb 2014
    Posts
    866
    Mentioned
    10 Post(s)
    Tagged
    1 Thread(s)
    very nice & neat example, i learned a few things from that

    tho i think u might still get the collision lag offset bug doing it that way.

  7. #7
    Clicker Fusion 2.5
    Rebel's Avatar
    Join Date
    Apr 2014
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    useful, thanks for share

Similar Threads

  1. Best way to go about screen shake?
    By ecoste in forum Fusion 2.5
    Replies: 10
    Last Post: 9th October 2015, 05:05 AM
  2. Screen Shake
    By Kentronisk in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 12th November 2011, 11:59 PM
  3. Pan and Shake Screen?
    By Vapyrical_Curse in forum Multimedia Fusion 2 - Technical Support
    Replies: 11
    Last Post: 12th July 2009, 07:00 PM
  4. how can I shake the screen !!
    By stairhead in forum Multimedia Fusion 2 - Technical Support
    Replies: 16
    Last Post: 17th March 2008, 10:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •