Asset - Project (All-in-One) GMS2 Camera with Screenshake, follow, screen-effects, and more

Discussion in 'Marketplace' started by JasonTomLee, Mar 9, 2019.

  1. JasonTomLee

    JasonTomLee Member

    Joined:
    Jul 20, 2016
    Posts:
    121
    This thread will serve as documentation for those who've purchased the asset

    Check out the main page on Itch.io



    Importing into your project
    First thing's first.
    How does everything work? Where do I start? How do I avoid breaking everything?​

    Initialization Room for Persistent objects
    I HIGHLY recommend using ONE persistent object to initialize all your 'one-time' variables at the start of your game. Whether it is your imported sprite fonts, window dimensions, controls, macros, particle systems/types, etc... this will organize & optimize your workflow.

    [​IMG]
    Place your PERSISTENT CONTROLLER object inside the FIRST empty room of your project.
    This will initialize your variables ONCE, go to the next room, and proceed to load your game. Nothing too complicated!



    Create Camera FIRST in every room you use it
    Because your 'Player' objects need to reference your CAMERA to set the Camera target, you must initialize the Camera first! Here are two ways you ensure it's done right:​



    [​IMG]
    • Initialize your objects within the Room's "CREATION CODE". Simply create your camera first and assign it to the proper layers/depths.​

    [​IMG]

    • Drag and Drop your objects the usual way, but make sure the Camera is on the wayyyy TOP. This ensures it is initialized before anything else.​

    Debugger Objects
    Does the UI 'bug' you? Simply press TAB to toggle it or remove the debugger object from your room.
    Here are the two debugger objects this asset uses:​

    1) General Debugger
    Displays general information. Info is displayed at the top half of the window.
    [​IMG]

    2) Cam Debugger
    Displays visual and text information about the Camera.
    [​IMG]



    Controls

    Mouse Controls
    Anything with a rectangle around it is a button. Interact with it using the Left Mouse button and scroll wheel.​

    Left Mouse: Toggle information
    Mouse Wheel: Scroll up/down
    Right mouse: Copy current Camera settings into a set of scripts.


    Keyboard Controls
    Tab: Toggle Debug
    WASD: Move demo player
    Shift: Adjust center
    coords
    C: Copy scripts ( same as Right click )





    Explaining the code
    There are two subsets of scripts: General and Camera


    General scripts
    The GENERAL folder contains a bunch of handy scripts I use in every project of mine. Check it out here

    Camera scripts
    wip

    [​IMG]





    Update List
    • Separate debugger code from the main Camera & Controller objects ( 3/9/2019 )
    • Use the same letter casing for global objects
    • Use consistent letter casing for scripts
    • Screen Flash scripts ( 3/9/2019 )
    • Screen Flash visual editor
    • Black Bars scripts ( 3/9/2019 )
    • Black Bars visual editor
    • Screenshake damping variables ( 3/9/2019 )
    • Add view-angle scripts / editor ( 3/9/2019 )
    • Target coord scripts ( move to a certain coordinate, not target obj )
    • Basic Shader functionality ( brighten,darken, bloom, contrast, etc... )


     
    Last edited: Aug 12, 2019 at 1:06 AM
  2. JasonTomLee

    JasonTomLee Member

    Joined:
    Jul 20, 2016
    Posts:
    121
  3. GeoffDev

    GeoffDev Member

    Joined:
    Sep 2, 2017
    Posts:
    5
    Good asset! Thanks! Some examples of how to use and trigger each of the camera scripts would be good. Such as using screen shake in a collision.
     
    JasonTomLee likes this.
  4. JasonTomLee

    JasonTomLee Member

    Joined:
    Jul 20, 2016
    Posts:
    121
    Appreciate it Geoff!
    Yea, I need to add proper documentation and examples sorry about that.
    I'm not completely satisfied with the system right now so I'm adding updates till it's the best it can be. So till then, it won't have any official documentation but I sure will add examples!

    Would video or GIF/text examples work better for you?
    thanks again man
    -jason
     
  5. GeoffDev

    GeoffDev Member

    Joined:
    Sep 2, 2017
    Posts:
    5
    Video examples are good if they walk through the process step by step. GIF/Image clips a hard because you can not explain things but screenshots with a detailed written explanation would be ok and easier to update if the asset changes. So far it is great. I have the following camera working and it works very well. Initializing it in a blank scene is a great tip and one that I am looking at using in my workflow moving forward unless somebody can show me a better way which makes sense and is easy for beginners to implement).
     
    JasonTomLee likes this.
  6. JasonTomLee

    JasonTomLee Member

    Joined:
    Jul 20, 2016
    Posts:
    121
    Code Examples:

    Here are a few practical examples using the debugger object:

    1) We will be using obj_player_demo for this example.

    [​IMG]


    2) Set the object as the Camera's target. You can find the Follow modes by typing "follow." because "follow" is a defined enum! Find and set new ones in the Create Event of the CAM.
    For this example, we'll be using mpeek. It's used for top-down games like Nuclear Throne.

    [​IMG]


    3) BLACK-BARS
    Try using the cam_bars_toggle() script. It toggles black-bars on/off.

    [​IMG]
    [​IMG]

    4) ZOOM
    -Set Zoom by placing the desired zoom value into the mouse_press event. This will zoom the camera in & pan back out to 1 on release.

    [​IMG]

    5) SHAKE
    -Set the camera shake type based on the "shake" enum. You will see the possible variables when you type "shake." (same for the follow enum).

    Small note: Setting -1 as the direction will make the shake go in random directions rather than one! It's best recommended for the jitter shake mode.

    [​IMG]


    6) Result
    -The end result of all our previous examples together! Here's the code for you to try out:
    Code:
    if ( !global.DEBUG ){[/SIZE][/LEFT]
    [SIZE=7]
    [LEFT]    if ( mouse_check_button_pressed( mb_left )){
            cam_bars_toggle();
        }
        if ( mouse_check_button( mb_left )){
            cam_zoom( 0.8 );
    
        } else if ( mouse_check_button_released( mb_left )){
            cam_bars_toggle();
            cam_zoom( 1 );
            cam_shake( shake.jitter, 32, 6, -1 );
            //cam_flash( c_white,0.4,3,1 );
        }
    }
    

    [​IMG]
     
    Last edited: Aug 12, 2019 at 1:46 AM

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice