1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

GMS 2 Controlling The View

Discussion in 'Programming' started by Pyxus, Jan 1, 2017.

  1. Pyxus

    Pyxus Member

    Joined:
    Nov 6, 2016
    Posts:
    195
    So in my rpg game I had an idea for the camera zooming in and out as a stylistic choice so that if you were, for example, selecting a player the camera would zoom in slightly towards that player, and if you then select the "move" option the camera would zoom out. I figured the best way to do this would be to have the view follow a camera object and the camera object changes the view depending on if you're selecting a player, or selecting an action. Exact numbers aren't necessary I just need to understand what i'd have to do to achieve my desired effect. I think I may have the right idea but so far room_set_viewpoty, camera_set_view_size, and camera_set_view_border, don't seem to do anything when I play with the numbers. Then again i'm pretty much an amateur and could just be doing something wrong.

    Here is all the relevant code... if you need any more information to assist me I'll post it in a heartbeat.
    Code:
    /// @description Move Toward Player
    ///Move 10% towards the player
    if (in_combat)
    {
        if(is_selecting_player)
        room_set_viewport(rm_battle, 0, true, 0, 0, 640, 480) //Messing Around With Function
        camera_set_view_size(obj_view,10, 10) //Messing Around With Function
        camera_set_view_border(obj_view, 10, 10) //Messing Around With Function
        x += (player_party[player_chosen].x - x) * .1;
        y += (player_party[player_chosen].y - y) * .1;
    }
    
    
     
  2. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,123
    You wouldn't change the view port, you'd change the view size itself. view_wview and view_hview.
     
  3. Perseus

    Perseus Not Ragarnak Forum Staff Moderator

    Joined:
    Dec 29, 2016
    Posts:
    953
  4. Pyxus

    Pyxus Member

    Joined:
    Nov 6, 2016
    Posts:
    195
    Thanks for pointing that out, though my mistake seems to be caused by my own stupidity ;P, I was using
    obj_view instead of view_camera[0]. By the way... I have a quick question if you're willing to answer/have an answer. In short I want to create a zoom effect and figured I could do this by increasing the width and height values until they reach the desired value but I'm not sure how best to do that. I'll probably find a solution through a bit of trial and error if not simply google, but it would save me some time. Thanks in advance!

    Code:
        if(is_selecting_player)
        {
        camera_set_view_size(view_camera[0], 1020, 716)
        camera_set_view_border(view_camera[0], 800, 540)
        x += (player_party[player_chosen].x - x) * .1;
        y += (player_party[player_chosen].y - y) * .1;
        }
        if(is_selecting_from_menu)
        {
        camera_set_view_size(view_camera[0], 800, 540)
        camera_set_view_border(view_camera[0], 800, 540)
        x += (player_party[player_chosen].x - x) * .1;
        y += (player_party[player_chosen].y - y) * .1;
        }
    
     

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