0

I'm currently building a game using Xcode, sprite kit and now tiled. The game is simple, a person jumping from 1 block to another, but if they hit the side it will be game over. Now is their anyway through tiled to create a block for the person to jump on. And through out the game to keep repeating and coming on for the person to jump on, I would like the object to have different heights and widths? Please Help?!

Larme
  • 24,190
  • 6
  • 51
  • 81
user1483652
  • 799
  • 1
  • 9
  • 16

1 Answers1

0

What you can go for is creating a reuse mechanism that will reuse nodes instead of creating and destroying them. A mechanism well-known from UITableView or UICollectionView.

You would implement a method:

- (SKNode *)dequeueReusableNode;

that gets reused SKNode from some storage, say, NSMutableArray (grabs first object from array, then deletes it from array and returns it). If array is empty, method returns nil.

Then you check if you got a node from the dequeueReusableNode method, if it's nil, you create a new instance of a node. If it's not nil, you configure it with your data. This goes for every visible node that should be reused.

Nodes that went completely off-screen are sent to reuseQueue – all their property values return to default state, and then node gets added to the end of the NSMutableArray that is the reuseQueue.

Rafał Sroka
  • 39,540
  • 23
  • 113
  • 143