[Solved] Set layer scale - Huge frame drop problem

0 favourites
  • 10 posts
From the Asset Store
A terrifying package of 101 professional-quality sound effects for monsters, small beasts, huge behemoths, dragons and m
  • Hi!

    In my game the player builds a tower. My game runs stable 60 Fps and is really smooth on my android phone.

    After the round I scroll to the middle of the tower and zoom out the layer to create a really cool effect.

    However when I zoom out the layer the FPS drop to like 1-5. When the layer has zoomed out the game returns to 60 fps again.

    I use 2 System events when the game ends:

    1. To scroll to middle of tower I use:

    Scroll to y (min(Scroller,scrolly+speedscroll*dt))

    2. While the game scrolls to middle of tower I also zoom out the towerlayer

    Set layer "Tower" scale to max(zoom,LayerScale("Tower")-speedzoom*dt) <-- Makes FPS drop to 1-5

    I'm using the runtime 3 and testing on a honor 9 lite

    Like I said. The frames only drop when the layer scale rate changes. If I create a small tower and the game does not need to zoom everything runs smooth when the round ends.

    Any idea why I cant't change layer scale rate?

  • Have you tested the GPU an CPU utilization? Which resolution do you use?

  • I'm using 720 x 1280 as resolution.

    On my android:

    CPU 20-30 % while playing (Goes to 30-40% when zooming out)

    GPU 10%

    On my computer: (On my computer the zooming works without any fps drop.)

    CPU 2% while playing (Goes to 5-10 when zooming out)

    GPU 0.5%

    Tried to scale out the whole layout but it does also massively drop the FPS.

  • GPU 10%

    when zooming out?

    Have you tried to zoom without scrolling?

  • It's almost impossible to help unless you share a sample project. Otherwise all anyone can do is throw out random guesses.

  • You are right Ashley.

    I'll look further into this tomorrow and find whats causing the Fps drop when I'm zooming out after the round has ended.

    I made an empty project and the zoomed out without any problem. If I'm zooming out during the start screen in my game the fps remains stable. (I'm guessing it's something like zooming and scrolling at the same is not good for CPU or maybe too many objects on the screen while scrolling and zooming)

    I'll try to start a new project and gradually add stuff to the game and test to see where the problem starts and share a project and a bit more info later. :)

  • boulerzzz

    I know on my iPhone and iPad that zooming does not work well if there are text objects on screen... the overhead with rendering text makes smooth zooming impossible. If you use SpriteFonts instead of text objects, then it may work fine. (it has fixed the problem for me)

    as a test, try hiding all text objects and then see if it zooms better...

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • AllanR Ashley

    Yes I found out that was the problem. My game is a word game and uses both cyrillic and latin letters so I though I would save time and simply use a webfont.

    Having more than ~20 text objects on the screen while zooming makes it impossible. Replacing them with spritefont makes everything smooff.

    Do you guys think I should replace ALL instances of my text object with a spritefont or just the ones that are visible while zooming? Should you use text objects at all in your games? :)

    Edit: In the manual it says: "Text rendering is very fast as long as the object is not changing, but upon changing the object must do a relatively expensive redraw of the text and replacement of the cached texture"

    In my game I got 12 text objects that are 115x115 in size and they change font color and position every tick. Are these "expensive redraws"? The text itself changes like every 10 seconds so that shouldn't be a problem, right?

  • boulerzzz

    the nice thing about the text object is that the text is always nice and crisp. SpriteFonts get a little blurry when zoomed too much. I found that using a high-res sprite font and scaling it down 50% generally gave the best results, and could still be zoomed in on without looking too bad...

    with only 12 fairly small objects, I don't think you will have a problem, but test it out in the debugger. I was working with a database and many hundreds of objects on screen at once.

    Ashley would have to answer whether changing colour every tick would be an expensive redraw or not. Changing the text content or size definitely would be, but position and colour might be ok... As long as your frame rate is good and the cpu utilisation is not too high, you should be fine.

  • AllanR

    Thank you for the help! (Y)

    I agree that text objects look nicer. I'll try using a larger sprite font and scale it down to see if I can notice an improvement. The spritefont still look quite good using a 1:1 scale as well IMO. :)

    I think I'm fine. Debugger shows low CPU usage and game runs well on my Honor 9 lite as well so color and position change might actually be OK...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)