Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

iOS and MacOS / FPS drop to 5 in iPhone 4S device and simulator

Author
Message
kslam212003
11
Years of Service
User Offline
Joined: 10th Dec 2012
Location:
Posted: 18th Dec 2012 10:02
Hi,
I got 10 sprites (80 x 100), 10 bullet (16 x 16). Running 25 FPS in iPhone 4S device and simulator.
If I run the AI code below, FPS drop to 5.





Any solutions to solve it ?


Thank you.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 18th Dec 2012 17:56 Edited at: 18th Dec 2012 18:10
It would help if you showed the definition of the alienship class. What you are showing isn't enough.

I would suggest making the myalienship array a static member of alienship and call the AI function, without any parameters, and use the static myalienship within the function?

You can create a static method in alienship that does the loop:


I moved the definitions outside of the for loops because it is a style I prefer (some languages, like JavaScript, really complain about defining variables as part of the for statement).

Also notice the parenthesis I added to the innermost if statement. it lets the compiler do a better job of optimizing it and makes sure the comparison is the correct one

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 18th Dec 2012 18:11
The repeated calls to GetSprite<whatever> take a lot more time than you think. Especially when you effectively do one hundred loops (10 x 10). That really adds up.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
kslam212003
11
Years of Service
User Offline
Joined: 10th Dec 2012
Location:
Posted: 19th Dec 2012 10:46
I forgot key in the pointer * to function in .h file.

replace this
void alienship::AI(alienship al[])

with this
void alienship::AI(alienship* al[])

problem solved.
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 19th Dec 2012 11:11 Edited at: 23rd Dec 2012 20:25
I would add sugesstion of creating an array and filling it with sprite dimensions (unsigned ints), either once (in case dimensions are constant), or occasionally (in case sprite dimensions change), then call array values in the loop without referring to GetSprite. This could add some fps()

Login to post a reply

Server time is: 2024-11-21 13:03:49
Your offset time is: 2024-11-21 13:03:49