Game Development Reference
In-Depth Information
Now as you can see, the screen color has changed to white but there is no ant on the
screen. This means something has gone wrong in the code. So, now let's check our logs,
which should be printing the following:
2014-07-22 19:13:27.019 AntKilling[1437:60b] Size: {320,
568}
So the scene size is wrong. The scene should print 568 as the width and 320 as the height
but it's printing the opposite. To debug this, navigate to your AKViewController.m
viewDidLoad method. You can find the complete code for this function at
AntKilling/AntKilling/AKViewController.m .
So, from this method, we can see that our scene is absorbing the size from the bounds of
the view and this viewDidLoad method is invoked even before the view has been ad-
ded to the view hierarchy. So it has not responded to the layout changes. Thus, because of
the inconsistent view bounds our scene is getting started with wrong bounds.
To solve this issue, we have to move the scene startup code in the viewWillLay-
outSubviews method. After removing the code from the viewDidLoad method and
pasting it to viewWillLayoutSubviews , you can find the complete code for this
function at AntKilling/AntKilling/AKViewController.m .
Now, once again build and run the app; you should see the following output:
Search WWH ::




Custom Search