GML Why does a copy of application_surface look scaled?

Discussion in 'Programming' started by Paskaler, Feb 8, 2017.

  1. Paskaler

    Paskaler Member

    Joined:
    Jul 4, 2016
    Posts:
    317
    So, I tried making a pause function within the game. All the objects get deactivated except the obj_pause itself and obj_environment which takes care of the background scrolling. Right before I deactivate everything I make a copy of application_surface using:
    Code:
    surface_copy(self.screen, 0, 0, application_surface)
    Below are two images, taken at the same location:

    Before pausing:
    unpause.PNG

    After pausing:
    pause.PNG

    Here's the entire code of the event where the surface is copied:

    Code:
    self.isPaused = !self.isPaused;
    
    if (self.isPaused)
    {
        if (!surface_exists(self.screen))
            self.screen = surface_create(surface_get_width(application_surface), surface_get_height(application_surface));
    
        surface_copy(self.screen, 0, 0, application_surface);
       
        instance_deactivate_all(true);
        instance_activate_object(obj_environment);
        instance_activate_object(obj_camera);
    }
    else
    {
        instance_activate_all();
    
        self.manual = false;
       
        if (surface_exists(self.screen))
            surface_free(self.screen);
    }
    
     
  2. Pixelated_Pope

    Pixelated_Pope Member

    Joined:
    Jun 20, 2016
    Posts:
    788
    Chances are you've set up views in the room editor and changed the port size of your game to be different from your view.

    When you do this, this changes the size of the application surface to be the size of your port, not the size of your view, so it will be much bigger. You can either resize your application surface at game start to be the same size as your view, or resize the window size with code rather than using the port settings. I have a comprehensive tutorial on all things view and scaling in GMS on my youtube channel (and posted under the tutorials section here on the GMC if you have further questions).
     
    Lonewolff likes this.
  3. Paskaler

    Paskaler Member

    Joined:
    Jul 4, 2016
    Posts:
    317
    Thank you for the lightning fast replies! I have the port scaled to be twice the size of the view. I'll try to fix it first thing in the morning and I'll be sure to check out the tutorials as well.
     
  4. Pixelated_Pope

    Pixelated_Pope Member

    Joined:
    Jun 20, 2016
    Posts:
    788
    I didn't even look at the code. lol! I've seen this way too many times.
     
    Lonewolff likes this.
  5. Ampersand

    Ampersand Guest

    I found the default application_surface so picky about built in variables and constants that I found it easier to make my own graphics buffer and view system. ymmv.
     
  6. RangerX

    RangerX Member

    Joined:
    Jun 20, 2016
    Posts:
    2,605
    Scale your game by the application surface and not port on screen. This is an example of multiple problems you will spare yourself. ;)
     
  7. PWL

    PWL Member

    Joined:
    Jun 21, 2016
    Posts:
    28
    Pardon me for asking, but what does that mean and how would that be done?
     

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