GMS 2 Performance: sprites vs drawing

Discussion in 'Programming' started by Pano, Nov 8, 2018.

  1. Pano

    Pano Member

    Dec 14, 2016
    I have to create 10 objects and about their sprites I have two possible ways: the first one is to create 10 images (different colors and text) and load them as 10 sprites; the second one is to create 4 images (different colors), load them as 4 sprite and then use drawing functions to write the text on them.

    So, I would to ask more expert users if is better, from a performance and tuning point of view, loading more sprites and use less drawing functions or loading less sprites and use more drawing functions. Targets are ios and android devices.

    Thanks, regards
  2. Marcus12321

    Marcus12321 Member

    Aug 29, 2018
    If I had to guess, I would say more sprites. As far as I know, GMS handles fonts as a sort of sprite in the background, so a line of text would be almost like multiple sprites.

    Edit to add:

    You might make it even faster if you put all of the sprites in a sprite sheet, then there would be no texture swapping. But, it would be more work progmatically.

    The truth is if you are just drawing 10 sprites, none of the methods are going to cause a big enough issue that it matters. Do it the easiest way possible for you.
    Pano likes this.
  3. ❤️×1

    ❤️×1 Member

    Sep 4, 2018
    Honestly : don't worry about that. This is optimization too early for sure; and if you can't spare the 3 minutes it takes to actually test it by yourself, you shouldn't even think about it.
    Pano likes this.
  4. sitebender

    sitebender Member

    Sep 13, 2016
    Sprites is far faster than drawing primitives. You can test this theory... draw 500 lines vs 500 draw_sprites of the same size and dimension. I've done it many times. Seems like drawing a giant surface is better performance wise than drawing a screen full of text.
    Last edited: Nov 8, 2018
    Joe Ellis and Pano like this.
  5. Joe Ellis

    Joe Ellis Member

    Aug 30, 2016
    In complete accurist's terms, its fastest to draw 10 sprites with all the text pre drawn onto them, but takes more ram ( I hope your ram can handle it )
    In my case I create surfaces with the sprite printed onto them and the text over the top, then draw them. Cus it's the slowest and pointless to draw the text every frame when you can save it to a surface and draw that.
    But 10 or 4 sprites, plus 10 texts, isn't gonna make a screw's difference with performance, but times that by 100 (the amount of times your doing it) and it does make a big difference, between the various options, the amount of time between each method takes becomes 100 times further apart and thats the stuff that lags the game, when it's happening 100's 1000's times over, but if this case is just with 10 or 4 sprites, doesnt make any meaningful difference

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