Game Maker Studio Tutorial: Camera Zoom (Scaling) Effect.


Hi there in this new video tutorial I’m going to show you how to implement in this new video tutorial I’m going to show you how to implement a zoom or scalling effect in Game Maker Studio a zoom or scalling effect in Game Maker Studio this is the effect I’m talking about zooming in, zooming out in a previous video I show you how to implement a camera rotation effect in a previous video I show you how to implement a camera rotation effect well, we’re going to use basically the
same approach but this time for zoom or scalling effect but this time for zoom or scalling effect but this time for zoom or scalling effect but this time for zoom or scalling effect ok, now let’s get back to the code I put all the code in a single object this is the object this is the object as you can see it has only two events in this create event we just need to add this zoom_factor variable in this create event we just need to add this zoom_factor variable in this create event we just need to add this zoom_factor variable in this create event we just need to add this zoom_factor variable we need to initialize it with
a value of ‘1’ and now let’ see this ‘Step’ event more in detail and now let’ see this ‘Step’ event more in detail and now let’ see this ‘Step’ event more in detail and now let’ see this ‘Step’ event more in detail here I’m decreasing the zoom_factor value each time I press the ‘add’ key here I’m decreasing the zoom_factor value each time I press the ‘add’ key here I’m decreasing the zoom_factor value each time I press the ‘add’ key here I’m decreasing the zoom_factor value each time I press the ‘add’ key and here I’m increasing the zoom_factor value each time I press the ‘subtract’ key and here I’m increasing the zoom_factor value each time I press the ‘subtract’ key and here I’m increasing the zoom_factor value each time I press the ‘subtract’ key and here I’m increasing the zoom_factor value each time I press the ‘subtract’ key and here I’m increasing the zoom_factor value each time I press the ‘subtract’ key once the zoom_factor variable value is modified I need to multiply it by my room’s width and height once the zoom_factor variable value is modified I need to multiply it by my room’s width and height once the zoom_factor variable value is modified I need to multiply it by my room’s width and height once the zoom_factor variable value is modified I need to multiply it by my room’s width and height once the zoom_factor variable value is modified I need to multiply it by my room’s width and height once the zoom_factor variable value is modified I need to multiply it by my room’s width and height once the zoom_factor variable value is modified I need to multiply it by my room’s width and height and once the multiplication is performed I need to assign this value to the current view and once the multiplication is performed I need to assign this value to the current view and once the multiplication is performed I need to assign this value to the current view and once the multiplication is performed I need to assign this value to the current view and once the multiplication is performed I need to assign this value to the current view remember in Game Make Studio the default view is ‘o’ remember in Game Make Studio the default view is ‘o’ so basically you want to replace this number here this ‘960’ you want to replace this with your room’s width you want to replace this with your room’s width you also want to replace this number here you also want to replace this number here this ‘540’ you want to replace this number with your room’s height you want to replace this number with your room’s height you want to replace this number with your room’s height you want to replace this number with your room’s height and basically this is all what you need and basically this is all what you need and basically this is all what you need to perform this scaling or zomming effect to perform this scaling or zomming effect as I said, is the same approach I use in the camera rotation effect as I said, is the same approach I use in the camera rotation effect as I said, is the same approach I use in the camera rotation effect as I said, is the same approach I use in the camera rotation effect basically modifying the view values you can obtain this effects basically modifying the view values you can obtain this effects basically modifying the view values you can obtain this effects basically modifying the view values you can obtain this effects basically modifying the view values you can obtain this effects basically modifying the view values you can obtain this effects this can be pretty useful for different purposes and for different type of games this can be pretty useful for different purposes and for different type of games this can be pretty useful for different purposes and for different type of games this can be pretty useful for different purposes and for different type of games okay, that’s all okay, that’s all I hope you find this video useful, see you.

52 Replies to “Game Maker Studio Tutorial: Camera Zoom (Scaling) Effect.”

  1. Like it? HA! I don't like it…I LOVE IT!!! It was easy to follow along even if your accent makes it a little difficult to understand. The codes work and you made learning coding fun!!

  2. Thnx dude, we were stuck in a middle of project and thought we will need to re do all the textures, but you saved us from that 😉

  3. how do you for the text of the left corner does not tranform with the camera move?
    sorry 4 my english u.u

  4. Marcelo, search in my videos for "Drawing Text With Rotated And/Or Scaled Views", you'll find the answer to your question there. Regards!

  5. Did you enable the use of views? did you add the objScaleView in the room? if that didn't solve the problem, please, send me more information so I can figure out what's going wrong.

  6. thnx for the tutorial, it also works on game maker 8.0! 😀
    but do a tutorial on having 1 view follow 2 chars like on ssbb for the wii

  7. You can "clamp" the zoom factor between a given range easily:

    [a, b]

    if (zoom_factor is lower than a) zoom_factor = a

    if (zoom_factor is greater than b) zoom_factor = b

    I can't post coding symbols here, I don't know why, anyways I think you get the idea.

    Hope that helps!

  8. You could just put room_width and room_height in place of those values you put in for the room dimensions.

  9. Thank you so much for this video, it's incredibly simple to implement in my game and very simple to understand and add bits too. Thank you.

  10. Hi there, I got a problem. When I zoom out or zoom in, the graphic gets bad. The sprites look stretched or smashed, but in your game, they doesn't! How did you do it?

    Sorry if my english sucks! Thanks!

  11. This is awesome, Thanks for this video. I have a question, when implementing a camera rotation  how do I keep my player relevant to the view of the camera…I want the player to be right side up so when he falls it is on his feet and not his head or some other part

  12. This code worked very well for me on gm8.1, but now using it on GMS Pro, it simply doesn't work. The variables go up and down but it is just this. Now I checked views and it turned all into black. x.x

  13. You're pretty good with that. Can you help me with some decisions? I want to make a full screen game. I'm not sure what the size of the sprites should be, I have the impression that even 150×70 is going to be good enough, but game maker seems fairly good with scaling… what do you advice me?

  14. Is there a way to do the following in a smother manner? It's a bit choppy in game. My room is 1280×1024 (my monitor size too). Create Event is just: Zoom = 1
    Step Event is as follows:

    if mouse_wheel_up() {
        if Zoom > .2 {
            Zoom -= .02;
                view_xview[0] = abs(Zoom – 1) * (mouse_x);
                    view_yview[0] = abs(Zoom – 1) * (mouse_y);
        }
    } else if mouse_wheel_down() {
        if Zoom < 1 {
            Zoom += .02;
                view_xview[0] = abs(Zoom – 1) * (mouse_x);
                    view_yview[0] = abs(Zoom – 1) * (mouse_y);
        }
    } else {
        Zoom += 0;
    }

    view_wview[0] = 1280 * Zoom;
    view_hview[0] = 1024 * Zoom;

  15. hi dear,
    Subscribed. i'm new in GML 🙂
    your tutorials are very helpfull, i understand. i have a problem in this this tutorial, i searched for solve of my problem but i didnt see any solve for it. The problem is that, when i zooming window is going to position (0,0). i want when i zooming it will go to where mouse. i tried window_set_position but it didnt help to me. 

  16. Awesome tutorial. It helped me a lot. The only problem is that when I scale in my game, it scales to the upper left corner, not to the center like in your game. Please, how do I fix this?

  17. Liked the tutorial! Unique and answers a common question.  could you describe what variable to limit the amount of zoom, like zoom max and minimum. i found that i was zooming so far in that it loops the images in reverse!…thank you

  18. so if I have views enabled do I need to do this differently?  because it gives me this error
    _________________________________________
    ############################################################################################
    FATAL ERROR in
    action number 1
    of  Step Event0
    for object obj_scale_view:Push :: Execution Error – Variable Get 100002.zoom_factor(100014, -2147483648)
     at gml_Object_obj_scale_view_StepNormalEvent_1 (line 12) – view_wview[0] = 640 * (zoom_factor);
    ############################################################################################

  19. I found this useful but needed to limit it. I added the following code in the step event

    if (zoom_effect < 0.2) {
    zoom_effect = 0.2 }
    else {
    if (zoom_effect > 1.5) {
    zoom_effect = 1.5 }
    }

  20. Hey, I am struggling finding a way to make my text sync with the view. For instance, when I zoom out, my text shrinks. I use the transformed text function so I can alter their sizes when zooming, but how exactly would I do this?

  21. How do you keep the camera centered in the view when scaling rather than the view scaling on the top left corner as the focal point?

  22. Christ, finally someone who explains what the code is doing and doesn't have overly complex code…Thanks!

  23. Thats just weird.
    For me it zoomes to the upper left corner first and then to the player after about 2 seconds
    Any ideas why?

  24. how can you just set a default zoom becaus i have one big room but want a small bieuw so that i have a default zoom thing

  25. For those of you having a problem with the camera being super glitch and zooming from the top left, put this code in the begin step event:
    beginstep: view_wview[0] = 1920 * (zoomfactor);
    view_hview[0] = 1080 * (zoomfactor);
    this fixed my problem, but it will only work if your view is attached to a smooth camera object… I think

Leave a Reply

Your email address will not be published. Required fields are marked *