I've been trying to create a simple view-changing app and no matter how many tutorials I watch and no matter how many samples I download I always get the same thing. When I click the button to change the view I get a blank white screen I think this has to do with 3.0 but it's probably just me! Thank you if you can help!
First thing I would try is reinstalling the SDK, sounds like something is corrupt if you can't run other peoples examples. Assuming here that you haven't modified the example project in any way.
Kinda hard to remember because I'm using cocos2d and scene switching now! Basically you should have UIViewController objects that contain UIView objects. When you initialise a view controller you are able to access its view object and add that as a subview of your window or another view if you have some sort of hierarchy going on. That is fairly simplistic though because Interface Builder fits into the equation too if you are using example code.
Okay I'll attempt to change up the code I have and try to get it to work. Is cocao2d very different from obj-c because that's probably alot more powerful for game programming.
You use objects called scenes and when you want to switch a scene you go [[Director sharedDirector] replaceScene:newScene], that kind of thing. Then you add sprites, layers etc. as children of the scene.
Cocos is too confusing for me right now I guess I'll wonder if anyone else can help me with my view switching problem?
Cocos actually works in a very similar way to UIKit except you don't have to worry about view controllers and nib files, it's actually more straightforward in my opinion Can you explain to me how you are going about view switching currently?
Well it turns out I did have to re-install x-code and I setup a view and create a view controller then I input this code in a IBAction [self presentModalViewControllerlayGameController animated:YES]; As for the confusing thing I get how it works but when I tried I couldn't get animation to work (it said I didn't declare something) and I like being able to draw stuff in interface builder.
Hmmm I prefer to avoid Interface Builder wherever possible except for views that have lots of static subviews. A modal view is normally used for dialog boxes that sit over the top of other views and are usually set to be the only views to receive user input. While this should work if you do this for all of your view switching you are going to end up with piles of views all on top of one another and all consuming memory so not the best approach. Trust me you will have enough problems with memory management as it is! Let's say that we already have a view loaded, named oldView, and it is the child of another view called parentView. If we want to replace the current view with a new one then we do this: Code: // create the new view controller from a nib file, this will automatically create a UIView for you UIViewController *newViewController = [[UIViewController alloc] initWithNibName:@"newViewNib" bundle:nil]; // add the newly created view as a subview of parentView [parentView addSubview:newViewController.view]; // remove oldView as a subview of parentView [oldView removeFromSuperview]; // don't forget to release newViewController, unless a reference to it needs to be stored [newViewController release]; I think that about sums it up in simple terms As far as animation is concerned it depends what animation you were intending to use?
Well I did something like this move = MoveTo(120, 430); (the name of my sprite).do move; I'm writing on my iPod so that's not exactly what it looked like.
Where did you find this code? This is not something you can do in UIKit. In fact it looks more like how you would do it in cocos2d! Chances are the error you were getting is telling you that MoveTo is undefined.
Ah right, I thought you had decided against cocos2d and were still using UIKit! In that case, to use MoveTo you do like so: Code: MoveTo *move = [MoveTo actionWithDuration:1.0 position:cpv(120, 430)]; [sprite runAction:move]; Have you managed to find the cocos2d API reference? Cos you're a fish out of water without it