How do I fix lag from custom font score?

Triangularity GamesTriangularity Games Founder/OwnerMarylandMember Posts: 140

I added a custom font score to my game and when I test it with the gamesalad previewer only the first point lags and then its fine (same with html 5 preview), but when I preview on an android device it lags every point. Basically, every 5 seconds a timer spawns an actor and adds a point. But this causes it to lag for a split second. Without the custom font score it works fine. Please help...thanks in advace!!

Comments

  • ArmellineArmelline Member, PRO Posts: 5,365

    Can you show the logic you're using for custom fonts, as well as the logic you use to change the score?

  • AngryBoiAngryBoi Member Posts: 586

    Mine used to lag too very badly and I took my game off the markets. I had to make the fonts smaller in Photoshop

  • Triangularity GamesTriangularity Games Founder/Owner MarylandMember Posts: 140

    @Armelline said:
    Can you show the logic you're using for custom fonts, as well as the logic you use to change the score?

    I did everything the video did except i dont have a RNG for the score. Mine is just +1. The logic for the score is i have a spawner and if an attribute (gamestart) is true then every 5 seconds spawn an enemy and add 1 to the score. Then in the custom font it changes the number.

    i also used this to hide the extra zeros.

  • Triangularity GamesTriangularity Games Founder/Owner MarylandMember Posts: 140

    @tappwater Games said:
    Mine used to lag too very badly and I took my game off the markets. I had to make the fonts smaller in Photoshop

    But does the size really matter? I shrink them down in game. I made the integer graphics 512x512, but in game they are 32x32. Would that cause the lag?

  • AngryBoiAngryBoi Member Posts: 586

    Yeah. In Photoshop just change them to 96x96. There won't be any lag.

  • AngryBoiAngryBoi Member Posts: 586

    I just make all of my images x3 of what they are in gamesalad

  • Triangularity GamesTriangularity Games Founder/Owner MarylandMember Posts: 140

    @tappwater Games said:
    I just make all of my images x3 of what they are in gamesalad

    Great advice thank you. Had a lot of graphics problems with my last game.

  • SocksSocks London, UK.Member Posts: 12,822

    @stephenriska123 said:
    I did everything the video . . .

    When you copy a method from a video there is the very real possibility that a mistake might have crept in somewhere, it could be as simple as a missing bracket or a wrong value, the fact that the method in the video works fine whereas your own version is having issues supports this idea. So it's petty much useless (from a problem solving point of view) to show someone the video you got your code from when they ask to see the code in your game !

    There are two versions of X, version X1 works fine, version X2 is having issues.

    Can I take a look at version X2 so I might see what the problem is ?

    Sure, here's version X1.

    :tongue:

    Hope that makes sense !

  • SocksSocks London, UK.Member Posts: 12,822

    @stephenriska123 said:
    But does the size really matter? I shrink them down in game.

    You are shrinking the actor and not the image, the image is still 512 x 512 pixels, even when on a 32 x 32 pixel actor.

    @stephenriska123 said:
    I made the integer graphics 512x512, but in game they are 32x32.

    I don't know what platform you are targeting, or what your build size is, but generally speaking you should make your images twice the resolution of the actor they will be applied to, so in this case they should be 64 x 64 pixels.

  • Triangularity GamesTriangularity Games Founder/Owner MarylandMember Posts: 140

    @Socks said:
    Hope that makes sense !

    Yeah. The problem was that my graphics for the numbers were too large and therfore were lagging the game when they were being called. And I'm still new to gamesalad and the forum so I dont now how exactly to share my code :neutral:

  • SocksSocks London, UK.Member Posts: 12,822

    @tappwater Games said:
    Yeah. In Photoshop just change them to 96x96. There won't be any lag.

    Generally speaking (i.e. applicable to the majority of devices) I'd recommend simply doubling the resolution, so his 32 x 32 pixel actors should have 64 x 64 pixel images, 96 x 96 pixels breaks the powers-of-two rule so the images will effectively be stored as 128 x 128 pixels, which is 4 times the memory usage of 64 x 64 pixels.

  • SocksSocks London, UK.Member Posts: 12,822

    @stephenriska123 said:
    Yeah. The problem was that my graphics for the numbers were too large and therfore were lagging the game when they were being called. And I'm still new to gamesalad and the forum so I dont now how exactly to share my code :neutral:

    The quickest way would be to simply grab a screenshot of the offending actor's rule - click the little black page icon at the top of the posting window, and point it to the screenshot.

  • Triangularity GamesTriangularity Games Founder/Owner MarylandMember Posts: 140

    @Socks said:
    The quickest way would be to simply grab a screenshot of the offending actor's rule - click the little black page icon at the top of the posting window, and point it to the screenshot.

    okay. thank you very much I will do that in the future. Triple size seems to work better because double size distorts a lot of the image and makes it look a little pixalized

  • SocksSocks London, UK.Member Posts: 12,822

    @stephenriska123 said:
    okay. thank you very much I will do that in the future. Triple size seems to work better because double size distorts a lot of the image and makes it look a little pixalized

    You can - to some extent - ignore the quality of your image assets in Creator, for example if we take an iPad (Retina) project as an example, your image assets will be displayed at half their final resolution in Creator - so deciding on your image resolution should really be done mathematically (or at least with an understanding as to what will happen to those images) rather than judging the quality by how they look when in Creator (using Creator's quick interpolation method).

    On the majority of target devices where resolution is X2, a X3 asset will be slightly blurred/aliased as - simply put - you will be asking the device to render 3 (image) pixels in the space of 2 (physical) pixels.

    And like I say triple sized images will use 400% memory usage of double sized image - with an actor size of 32 x 32 pixels.

  • Triangularity GamesTriangularity Games Founder/Owner MarylandMember Posts: 140

    @Socks said:
    And like I say triple sized images will use 400% memory usage of double sized image - with an actor size of 32 x 32 pixels.

    so. how can i make a graphic that small that isn't pixilized? Like if its 16x16 in game i have to design it at 64x64, but what if I want it to look really nice without seeing individual pixels?

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2015

    @stephenriska123 said:
    so. how can i make a graphic that small that isn't pixilized?

    Make it at the appropriate resolution, if your target device is a Retina iPad for example, make the image twice the resolution of the actor.

    @stephenriska123 said:
    Like if its 16x16 in game i have to design it at 64x64.

    If an image is displayed at 16 x 16 pixels in your project - and the target device is a Retina iPad - you would need to make your image asset 32 x 32 pixels.

    @stephenriska123 said:
    but what if I want it to look really nice without seeing individual pixels?

    I'm not entirely sure what you mean by that. There aren't really any values like 'really nice' in digital imaging ! :smile: if you make the pixels in your image match the pixels on the target device's screen 1:1, this will give you the optimal image fidelity, making the image lower than 1:1 resolution will produce interpolation artefacts, making the image higher than 1:1 resolution will also produce interpolation artefacts.

  • Triangularity GamesTriangularity Games Founder/Owner MarylandMember Posts: 140

    @Socks said:
    And like I say triple sized images will use 400% memory usage of double sized image - with an actor size of 32 x 32 pixels.

    sorry if this is hard to understand, but how do people make graphics that look like they were made at 1024x1024? (meaning there is no pixilation at all) and it would not be that big in game but it still has to access that large of a graphic.

  • SocksSocks London, UK.Member Posts: 12,822

    @stephenriska123 said:
    . . . how do people make graphics that look like they were made at 1024x1024?

    Author the image at 1024 x 1024 pixels ?

    @stephenriska123 said:
    (meaning there is no pixilation at all)

    Pixelation is not caused by an image's size.

    @stephenriska123 said:
    and it would not be that big in game but it still has to access that large of a graphic.

    I'm not 100% what the question is, but if you want a 1024 x 1024 pixel image you would simply make the image that size ?

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069

    @stephenriska123 said:
    sorry if this is hard to understand, but how do people make graphics that look like they were made at 1024x1024? (meaning there is no pixilation at all) and it would not be that big in game but it still has to access that large of a graphic.

    Resolution independence decides what graphics size is displayed based on the device on the back end. Each device has an aspect ratio it follows. Your goal is to make the highest resolution graphics for the aspect ratio of the devices you intend to target.

    Best practice in GS is generally accepted to be iPad project with 2x images. So 2x1024= 2048x2048 for an actor you want sized at 1024 in run time.

    "pixelation" can be caused by not only the resolution, but the devices display itself, and the rounding of the graphics being scaled. Thus avoiding 3x or odd sizes can be important.

    Follow us: Twitter - Website

  • Triangularity GamesTriangularity Games Founder/Owner MarylandMember Posts: 140

    @AlchimiaStudios said:
    "pixelation" can be caused by not only the resolution, but the devices display itself, and the rounding of the graphics being scaled. Thus avoiding 3x or odd sizes can be important.

    but isnt that too big. meaning wont that lag the game trying to load images that big?

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069

    @stephenriska123 said:
    but isnt that too big. meaning wont that lag the game trying to load images that big?

    It's all relative. Yes 2048x2048 is big, but will only be used on devices with retina displays. Otherwise it will use 1024. And that's for memory too.

    It really comes down to the individual game. One 2048x2048 is fine. 20 might not be.

    Basically in any given scene as a total you don't want you memory to exceed or come close to the limitations of the device. Not all devices have the same limitations.

    Lag can also be caused by cpu usage. This is generally solved by writing logic that is well optimized.

    Follow us: Twitter - Website

  • Triangularity GamesTriangularity Games Founder/Owner MarylandMember Posts: 140

    @AlchimiaStudios said:
    Lag can also be caused by cpu usage. This is generally solved by writing logic that is well optimized.

    gotcha. Thank you so much for the support :smile:

  • SocksSocks London, UK.Member Posts: 12,822

    @AlchimiaStudios said:
    "pixelation" can be caused by not only the resolution, but the devices display itself, and the rounding of the graphics being scaled. Thus avoiding 3x or odd sizes can be important.

    Making your image assets X3 will not cause pixelation, in fact it will help with pixelation ! :smile: . . . as it will blur/alias the pixels, and pixelation is petty much the opposite (problem).

    **With the one caveat that an iPhone 6 plus (and only the iPhone 6 plus, not the iPhone 6) does require X3 assets, although like you say working towards the iPhone 6 plus with an iPad Retina (X2) project is probably a better idea unless you specifically only want to target the iPhone 6 plus.

  • AngryBoiAngryBoi Member Posts: 586

    Wait so should I go change all of my images? They are all x3

  • SocksSocks London, UK.Member Posts: 12,822
    edited July 2015

    @tappwater Games said:
    Wait so should I go change all of my images? They are all x3

    This - and everything else mentioned in this thread - is entirely dependent on a number of factors, questions like 'should I make my actor be 1,000 x 1,000' or 'what's the best resolution for a picture of a dentist'** or 'is 400ppi better than 200ppi' are largely meaningless without context, it's hard to say anything about the requirements for optimal image fidelity for your images without knowing anything about your project.

    **230 x 230 pixels.

Sign In or Register to comment.