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.

AppGameKit Classic Chat / my game runs very slow ,how to solve it?

Author
Message
halley
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 22nd Sep 2011 05:29
when I created one sprite ,the fps is 20. created several : 6 or 7. nothing:60

I just created several sprites, the fps come down to 6 or 7. what's the reason? I think I'll create more than 200 sprites in my game.

is there anyone can help me ?

give my best
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 22nd Sep 2011 07:06
Are you creating the sprites inside the main do loop? If so try moving the createSprites outside the loop or add an if (getSpriteExists() = 0) filter around the createSprites.

the12thplaya
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 22nd Sep 2011 07:24
Hmmm, that's interesting... I tried adding the filter I mentioned around the createSprites lines in the main do loop and the FPS decreases as it's running meaning that every loop it must be creating 7 new sprites, ignoring the getSpriteExists filter.

Most of my sprites are loaded in a preload function which is only called once so I'm not experiencing this problem in my project but I have noticed some slowness and I'm often checking to see if a sprite exists before creating it so I may have to re-look at my code.

Here's the code that shows the number of sprites increase, fps decrease and the getSpriteExists() functions being ignored each loop



I added print(getSpriteExists()) lines at the top of the loop and they all showed 1 so maybe I'm writing the if lines wrong?!

the12thplaya
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 22nd Sep 2011 07:28
I've just seen an error in my above code which is causing the problem. The 4th if line is checking for testSprit4 and not testSprite4. This is why the sprite count is increasing and fps decreasing. Once I corrected this typo it ran at about 60fps and the number of sprites never increased past 7.

the12thplaya
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 22nd Sep 2011 07:57
I wouldn't recommend loading your files in a do loop like that. Take them all out and place before the do loop. That way they are created and then will be displayed at the co-ords you have chosen. You can then change position as you need from within the do loop.

halley
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 22nd Sep 2011 09:17
I understand what you said. I didn't put my creation of the sprites into the main loop, just at the begin function.

I think maybe it's the problem of IPAD simulator. The same project ,when I use iPhone simulator,the FPS is 30. and when I use iPad simulator ,FPS is 7.

Can anyone tell me how to change the settings of simulator? how to solve the problem?

give my best
Mike Johnson
TGC Developer
21
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 22nd Sep 2011 11:35
Have you upgraded to Xcode 4? I found that upgrading result in a much better frame rate within the iPad simulator.

It will be useful if you can provide more information, such as the size of sprites, how you are creating them, what is going on in your main loop etc.
halley
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 22nd Sep 2011 11:57
my Xcode version is 4.1


the background picture size is 1024*768. its format is PNG.

I just created one sprite with the picture, the FPS fall down to 20.

I really feel puzzled.

give my best
Mike Johnson
TGC Developer
21
Years of Service
User Offline
Joined: 13th Sep 2002
Location: United Kingdom
Posted: 22nd Sep 2011 12:55
Have you tested this app on the device? It should run at 60 fps without any problems.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 22nd Sep 2011 13:03
I don't think he can understand that the emulator can never be as fast as the ipad hardware, so that's why he's getting low fps, because he only has the emulator to test on
halley
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 22nd Sep 2011 13:07
now I don't have the apple development account. So I have to run the game in the simulator.
just now I observed the CPU usage. it is 100%.
I think I must take some mistakes, but I don't know where is the problem.
Can u give me more help? I'm very appreciate.

give my best
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 22nd Sep 2011 15:15
halley, it may indeed be the simulator, however if you post your entire code, we can take a look and hopefully rule out any wrong doing...
halley
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 22nd Sep 2011 15:48
I think it's the problem of simulator.Thank you very much.

give my best
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 22nd Sep 2011 16:46
The first time I ran my code on the iphone simulator it ran at 12fps! I was really angry! I then ran everything on the 3gs and magically all worked smoothly at 60fps!

simulator is only good as a visual aid not to full fps.
halley
12
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 22nd Sep 2011 16:55
I really spend a lot of time to examine my code. it is a pity that I didn't ask in the forum at first .

Thanks a lot.

give my best

Login to post a reply

Server time is: 2024-04-19 03:23:53
Your offset time is: 2024-04-19 03:23:53