Phone performance issue

0 favourites
  • 11 posts
From the Asset Store
Firebase: Analytics, Dynamic Links, Remote Config, Performance, Crashlytics on Android, iOS & Web Browser
  • This isn't a question about general phone performance. I'm aware that they're not as powerful as PC's by a long way and this is just testing on local LAN. But it seems a bit strange, so wondering if it's something I'm doing wrong or is to be expected.

    Very basic so far, just working on a simple vertical shooter. Runs at 60fps with about 50 sprites, slows down slightly after that but I expect that so I intend to keep the sprites to 50 or so max.

    But what does seem strange is, when I move my player ship with touch control, that slows down the FPS to about 45-50. Now the calculation for moving the ship is slightly complicated, but it's still only one calculation. I know phones are slow, but should a single 'complicated' piece of math make a performance hit like this?

    The code for the movement is ...

    If....

    Touch > Is in touch

    Distance (Player.X,Player.Y,Touch.X,Touch.Y) > 750 x dt

    then ....

    Player

    Move(Min(750*dt(Distance(Self.X,Self.Y,Touch.X,Touch.Y) pixels at Angle(Self.X,Self.Y,Touch.X,Touch.Y)

    Ok, that's a bit complex and it happens every frame, but should it really cause a 10 fps performance hit? I can speed it up of course, but just wondering if I'm missing something here.

    I should point out that it's not something else causing this. For example if I turn off all bullets and aliens and everything else, the movement alone still causes a large FPS drop. Is it just the code doing that?

  • Are you using the "is touching" check? If so, it could be causing the slow down since it seems that it causes a check to be run on every tick. This might be even worse depending on the mobile device that you were testing on (Android phones especially).

  • I have the same issue, but I'm also using 'is touching'

    Sigh, I wish there was consistency on this issue. The devs say not to 'waste' time optimizing and to 'develop for touch devices', but there isn't clear documentation or tutorials on the trickiness of handling multiple touches. Even worse is the fact that we MUST optimize if we're using touch controls, and there is little to no documentation on how to do this.

  • Ahh, does sound like the same thing then because I am using 'Is in touch'. It's as if touching the screen itself is causing the device to struggle.

    Is there a better method? Only check every 0.1 seconds or something?

  • Adding touch events like you've described should not affect the framerate at all. I suspect you're not seeing the real framerate when not in a touch. When nothing moves on screen at all, C2 doesn't redraw the screen, so you'll likely hit 60 FPS (because it's not actually doing anything). As soon as you start changing stuff on screen it starts redrawing, so if you move an object in a touch it will start redrawing every frame and then you get a realistic framerate measurement. This doesn't mean the touch events are really slow, it just means you're seeing the real framerate, not 60 FPS because it's inactive.

  • It's not that Ashley. I do have stuff on my screen. I have a basic shooter (basically the example shooter with a few of my own bits added) and it does run at 60 fps. If I put around 50 sprites on, it starts to slow down, which I'd expect. But the touch completely drags it down to 43 or so, regardless of how many objects are on screen.

    I can confirm that the same thing happens on the example vertical shooter. It runs at a near-steady 50 fps since the number of objects on the screen doesn't vary much (if you don't move) but as soon as I start moving, it drops to 35 (bearing in mind that moving tends to kill more enemies too).

  • I don't believe that its the actual touch event, more that you're using a constantly checked touch event that re-draws your ship every time that it returns true (so it is redrawing every tick while they are touching the screen).

    I'd say try regulating the event to a larger timeframe like you suggested farflamex or just have an on-touch condition that sets where the user touched into a variable, and then have your ship move towards those variables whenever they do not match its current position.

    ie.

    on touch

    then set positionX to touchX and positionY to touchY

    if shipX does not equal positionX and shipY does not equal positionY

    then move shipX towards positionX and shipY towards positionY

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The ship is drawn every frame either way though? Even if it just sits still, it's still redrawn. The only thing that changes with the touch event is the event itself and even if change that to do nothing at all (so it's just an empty 'Is in touch', it causes a slow-down of at least 10 fps. This is with the example shooter.

  • If that's the case, then Ashley's response seems to be the most logical.

  • The ship is drawn every frame either way though? Even if it just sits still, it's still redrawn.

    What Ashley is saying, is that when no objects are moving/changing in any way, even though the image remains on the screen, the game/GPU isn't actually drawing anything, it's just letting the previously drawn image linger, which means less work and often higher fps. It's possible touching the screen could be causing it to redraw the screen.

    Try adding a sprite that does nothing but rotate every tick, then try the test again. What happens?

  • It's not just a ship on a screen which sits still. There are other ships and sprites which are constantly moving, so the entire screen is being redrawn either way.

    Take the example vertical shooter. Add an FPS text to it.

    The enemy ships constantly move and your own ship constantly fires. So the screen is being refreshed and redrawn correctly. My phone shows 50 fps if I don't touch the screen. If I touch the screen and the ship starts to move, it drops to 35.

    Even if I remove the actual moving code and just have 'Is in touch' and then have zero actions, it still drops to 35, just by touching the screen. If I HOLD a certain location, it moves back to 50fps, but if I move my finger around the screen, it drops to 35 or less (even though now your ship doesn't move because I've removed the code, but the other ships/bullets are still moving).

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