Phone performance issue

Discussion and feedback on Construct 2

Post » Tue Apr 16, 2013 9:24 pm

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?
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Wed Apr 17, 2013 3:42 am

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).
B
21
S
7
G
5
Posts: 89
Reputation: 5,967

Post » Wed Apr 17, 2013 5:26 am

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.
Project Lead of Zems Online Card Game

Producer at Impulse Limited
B
18
S
6
G
3
Posts: 677
Reputation: 5,194

Post » Wed Apr 17, 2013 9:53 am

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?farflamex2013-04-17 09:55:48
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Wed Apr 17, 2013 2:39 pm

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.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,610

Post » Wed Apr 17, 2013 5:30 pm

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).
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Wed Apr 17, 2013 9:08 pm

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
B
21
S
7
G
5
Posts: 89
Reputation: 5,967

Post » Wed Apr 17, 2013 11:00 pm

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.
B
25
S
5
G
3
Posts: 446
Reputation: 5,633

Post » Thu Apr 18, 2013 1:25 am

If that's the case, then Ashley's response seems to be the most logical.
B
21
S
7
G
5
Posts: 89
Reputation: 5,967

Post » Thu Apr 18, 2013 1:32 am

[QUOTE=farflamex] The ship is drawn every frame either way though? Even if it just sits still, it's still redrawn.[/QUOTE]

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?Arima2013-04-18 01:34:13
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Next

Return to Construct 2 General

Who is online

Users browsing this forum: shinichild and 12 guests