Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Game with Sprite Kit Game Loop and Texture Atlas Understanding the Game Run Loop

frame jump in finished game

I have been playing this game on my iPhone and it still does frame jump? how can l resolve this?

2 Answers

The best way to fix the problem is to do what is called object pooling.

The reason for the frame jump is you are creating pieces of the ship, ships, and bullets and creating a lot at once. Creating new objects or allocating memory is an expensive task for the CPU. So you see the frame skip a bit.

Object pooling is where you create lets say 30 bullets ahead of time and track which ones are being used and which aren't Use the ones that are not being used and instead of deleting them when they are off screen you would put them back into the pool and use it later.

Easiest way to do it is precreate them on load and put them in an array. Then track which was the last one you took and take the next one.

If you do this for bullets and cats and pieces you will have no frame jump at all.

any documentation of sample code available anywhere please?

There are lots of things about object pooling on the web. You can do a quick google search to figure out the basics, but I outlined them for you here.

If you want to try it and get stuck I would be happy to help, but I don't know of any resources that specifically outline how to do this in sprite kit.

Which iPhone are you using? (4, 4s, 5, 5s) Are you loading the version from the store, or from the source? Where in the game does it start to frame jump? Can you relate any part of the game to when the frame jump happens, such as when you shoot?

l am using iPhone5 and a loaded version from the AppStore. the game frame jumps through the game when they are alot of cats coming in and you tapping to shoot them all. hope you get what i mean. Would just be greate to know how to resolve this as after watching this video there is only one thing pn my mind i wanna do for ma first project thus design and build a game