ios - Replacing (background) node gives weird result / nodes not visible on screen -
I'm trying to get into iOS with Spritekit for iOS, and I Ios Ray Wanderleach <
Now I am working on a platform game, but when trying to do nothing in the book, I get some strange results Used to be.
Actually, I have a work platform that loads the level from a JSON-file, and shows bricks / nodes in the background layer. I have to do several floors , so when a user jumps through a portal in the game, a new floor / level is loaded and placed in the same position on the screen (all floors have the same size ).
I did not think I would have any problem with it, as if the user jumps through the portal then it is really easy. And I'm already loading a level to start, so at this time another load is going and it should not be difficult to change the original.
However, it is proving to be very difficult. When I load the game, I call this method:
- (zero) vs. world {_bgLayer = [Self generated sensor: [NSNumber number with Interfer: 1]]; _worldNode = [SKNode node]; [_worldNode addChild: _bgLayer]; [Self compound: _worldNode]; Self.anchorPoint = CG Pointsmake (0.5, 0.5); _worldNode.position = CGPointMake (-_bgLayer.layerSize.width / 2, -_bgLayer.layerSize.height / 2); }
This initiates a level (floor 1) from a JSON file, which is basically the same as the map with 32x32 nodes located next to each other. It then creates a worldNode
, adds bgLayer
to worldNode
, and then adds it to the screen. Later it focuses on the worldNode
on the screen. worldNode
is the node that runs when a player runs, bgLayer
is always constant
When a user jumps through a portal , Then I call this method:
- (zero) outgoing up {if (_isChangingFloor); _isChangingFloor = Yes; [_bgLayer removeFromParent]; _bgLayer = Zero; [_worldNode removeFromParent]; _worldNode = Zero; _bgLayer = [Scannery of Creating Self: [NSNumber NumberEntega: 0]]; _worldNode = [SKNode node]; [_worldNode addChild: _bgLayer]; [Self compound: _worldNode]; _worldNode.position = CGPointMake (-_bgLayer.layerSize.width / 2, -_bgLayer.layerSize.height / 2); }
This method was not always "complete", as I thought I could replace After jumping through the portal, I get the result: As you can see, 1 node is on the screen, though debug-info says that there are 446. I believe this is the number of total nodes on the entire floor, but only about 90-100 should be visible at a time. I have tried to add / remove nodes from the level, which increases / decreases this number. That's because you might all understand, I'm really confused. When I leap through a portal, why does not it change the old background with a new place? There is nothing wrong with the JSON-file, because I have tried to initially load I've been stuck on it for several days, and I really appreciate someone that will help me get closer to a solution Thanks in advance! bgLayer
with just one, it was not working So, now I am trying to reset everything, at the start time, what happens in the create world {/ code> method. However, this does not work either ...
floor0
, and it works fine only when the behavior does not start when jumping through the portal Why is not such behavior? What's different here? Why does it call 446 nodes on the screen when clearly 1 is only. Why is there only 1 node on the screen?
I think you should check the _bgLayer's zposition every time you remove and add It may happen that your problem be restored
Comments
Post a Comment