Thanks, I'd love to make it better if you had any suggestions.
Now in your code you had a few mistypes.
In MyCustomView.h:
//Put your global game variables here, but don't set a value to them!!
//This works: int test;
//This doesn't: int test = 0;
CGPoint postion;
int xVel;
int yVel;
'position' is spelled as 'postion'. That leads the compiler to believe you hadn't made this variable when you try to use it.
In MyCustomView.m:
- (void) awakeFromNib
{
screenDimensions = CGPointMake([[UIScreen mainScreen] bounds].size.height, [[UIScreen mainScreen] bounds].size.width);
//Set any global variables you have made here.
//For example, test = 10;
xVel = 0;
yVel = 0;
positon = CGPointMake(50, 50);
You spelled 'position' as 'positon'.
- (void) handleGameTimer: (NSTimer *) gameTimer {
//All game logic goes here, this is updated 60 times a second
positon.x += xVel;
positon.y += yVel;
//This updates the screen
[self setNeedsDisplay];
}
Same error here. Just change 'positon' to 'position'.
And finally you had an error in drawRect:
- (void) drawRect:(CGRect)rect
{
CGContextRef context;
//To set a color for a shape:
float color[] = {1.0,0.0,0.0,1.0};
//ALL DRAWING CODE GOES HERE
[self drawOval:context translate:CGPointMake(0,0) color:color point:position dimensions:CGPointMake(10,10) rotation:0 filled:True linesize:0,0];
}
The error is that you have 'filled:True'. In Obj-C you want a boolean to be fully capital: 'filled:TRUE'. Finally your 'linesize:0,0' has an error. That comma should be a period.
No big errors, all good. :) Perhaps I'll make a debugging tutorial...
-Gan
P.S. If you don't want to have to upload rtf files, you could just zip the source and send that.
Your source was perfect except for:
background = [self loadImage:@"background" type:@"png"];
ball = [self loadImage:@"ball" type:@"png"];
Your images have capitalized first letters, so it should be:
background = [self loadImage:@"Background" type:@"png"];
ball = [self loadImage:@"Ball" type:@"png"];
-Gan
Hi Gandolf,
I'm totally new to Obj-C and not really sure of the scope of instances... I want my game engine object to be able to send messages to my view obect and vice versa, but as I understand it I need to have a Controler object which has instances of both my view class and my game engine class... Then the controller need to mediate between the two... This is a new way of working for me and will require reworking my game code a great deal...
I believe you wouldn't need to do such things. My obj-c lingo isn't very refined but I believe a good answer for this problem is to integrate the game engine class into the view class. If you want to post your source I can give you a better answer or if you don't feel comfortable you could post a dummy source which doesn't reveal any of your actual code.
Second question, I have built custom UIObjects (buttons which are animated), but they need to be animated with respect to the touch input. (i.e. Touch movement cause the icon to change more White if the touch moves up, more black if moves down etc...).. How can I do this, giving realtime feedback, without blocking the main thread of execution (and other animations)?
You can put UIObjects right in the UIView class and it'll run perfectly with your game or you could make your own kind of a non-UIObject basic button(Shown in tut #3). As for changing colors of the animation, would be possible using the NSTimer but I haven't experimented with that sort of thing.
Third question... Does the AppDelegate run in a separate thread? What can I use this class for?
As far as my knowledge, the AppDelegate probably doesn't run in a separate thread but I'm a bit unsure of that. This class can be used for a ton of great stuff, gets deep in your app and can access your view controlls and the view itself. Of course by using commands you can access it from the view or controller itself giving you access to everything in your app anywhere you need it. Works amazing if you want code that runs before your app quits or if you want to be able to set a responder for a UIObject.
Sorry if I didn't give the answer you wanted though if you could point me in a better direction than I might be able to be more on track.
-Gan
Thanks Gandolf!
I tried it like this:
- (void) handleGameTimer: (NSTimer *) gameTimer {
//All game logic goes here, this is updated 60 times a second
float slower = .99;
velocity.x = slower * velocity.x;
velocity.y = slower * velocity.y;
position.x += velocity.x;
position.y += velocity.y;
if(position.x <0) {velocity.x = velocity.x;}
if(position.y <0){velocity.y = velocity.y;}
if(position.x >screenDimensions.x-30) {velocity.x = -velocity.x;}
if(position.y >screenDimensions.y-30) {velocity.y = -velocity.y;}
//This updates the screen
[self setNeedsDisplay];
}
But the ball now disappears off the top of the screen. See anything that explains it?
I'm not usually this thick-headed about this stuff, but I've been banging my head against this for a while now...
Thanks Gandolf. I think I solved it.
The problem was related to applying the "friction" before I placed the ball. When i moved the float etc below the rest of the code it worked out.
I still have no idea what was causing the "wall" to disappear though. Although I did discover that if I add something like
if(ballVelocity.x < .01) {
ballVelocity.x =0;
}
the right-hand wall disappears, even in a fresh project which works fine otherwise. Strange.
Now to figure out how to start the ball with a swipe and have it move in the direction of the swipe... ???
For an effective wall I'd use:
if(position.x < 0) {
ballVelocity.x *= -1;
position.x =0;
}
That'd fix it. Then you'd just need to apply this code to the different walls too.
For your velocity, that's a good idea.
For gettings the direction and length of the swipe just make a variable of where the finger starts and a variable for when the finger ends. Use touchBegan and touchEnded to make it work. That'll give you a line pointing you in the right direction in which all you need to do is some trig to set the correct velocity. Then using pythagorean's theorem you can get the length of that line.
-Gan
Does that wall reverse direction or bring it to a stop? How about:
ballVelocity.x = -ballVelocity.x;
ballVelocity.x = ballVelocity.x / 2;
To sow it down? Or would that not work?
Right i wanted it to slow gradually, all along its path. I used this:
float friction = .99;
velocity.x =velocity.x * friction;
velocity.y = velocity.y * friction;
And it worked like a charm. I tried .5, but at 60 fps it was completely stopped nearly instantly.
Hmm. Try this:
NSString* loopCounterTxt = [NSString stringWithFormat:@"%d", loopCounter];
[self drawString:context translate:CGPointMake(0, 0) text:loopCounterTxt point:CGPointMake(0, 0) rotation:0.0 font:@"Helvetica" color:color size:12];
That should do the trick. Another way to turn an int to a string may be: [loopCounter stringValue]; .
-Gan
Make an NSMutableArray.
NSMutableArray* highscore = [NSMutableArray new];
Add your score to the NSMutableArray.
[highscore addObject:[NSNumber numberWithInt: 253]];
Then run the save command:
[self saveFileInDocs:"Highscore.txt" object:highscore];
That'll save the score 253 in the file "Highscore.txt";
Now to open:
NSMutableArray* highscore = [self openFileInDocs:"Highscore.txt"];
int scoreNumber = [[highscore objectAtIndex:0] intValue];
That's how you retrieve and save data.
-Gan
Here's the code to detect the current OS:
if ([[[UIDevice currentDevice] systemVersion] floatValue] < 4.0) {
//Less then 4.0
} else {
//4.0 or greater
}
To check if your file exists just load it as normal and do this:
if (testFile == nil) {
//File doesn't exist
}
I will see about converting it but still pretty busy.
-Gan
I tried with the file stuff for highscores, but when my program gets to the part where it's supposed to check highscores and update the file, it crashes. Any help?
int score = loopCounter;
if (!gottenScore) {
NSMutableArray* highscore = [NSMutableArray new];
highscore = [self openFileInDocs:@"Highscore.txt"];
if (highscore != nil) {
if (score > [[highscore objectAtIndex:0] intValue]) {
[highscore replaceObjectAtIndex:0 withObject:[NSNumber numberWithInt:score]];
gotHighscore = TRUE;
}
[self saveFileInDocs:@"Highscore.txt" object:highscore];
}
else {
[highscore addObject:[NSNumber numberWithInt:score]];
[self saveFileInDocs:@"Highscore.txt" object:highscore];
}
gottenScore = TRUE;
[self drawString:context translate:CGPointMake(0, 0) text:[NSString stringWithFormat:[highscore objectAtIndex:0]] point:CGPointMake(0, screenDimensions.y-130) rotation:0 font:@"Arial" color:color size:20];
if (gotHighscore) {
[self drawString:context translate:CGPointMake(0, 0) text:@"HIGHSCORE!" point:CGPointMake(70, screenDimensions.y-80) rotation:0 font:@"Arial" color:color size:20];
}
}
To make it stay in portrait mode go to the left bar, go to the Resources folder, click the Info.plist file then change the UIInterfaceOrientation to UIInterfaceOrientationPortrait.
Then to make OpenGL draw for portrait mode you...
Replace the drawImage method with this:
- (void)drawImage:(Image*)image AtPoint:(CGPoint)point {
[image renderAtPoint:CGPointMake(point.x, 480-point.y - image.imageHeight) centerOfImage:NO];
}
Replace the 3 touches methods with this:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
NSArray* allTouches = [touches allObjects];
NSArray* eventTouches = [[event allTouches] allObjects];
for (int i = 0; i < [eventTouches count]; i +=1) {
if ([eventTouches objectAtIndex:i] == [allTouches objectAtIndex:0]) {
//touchedScreenBegan1 = [[eventTouches objectAtIndex:i] locationInView:self];
//Rotated touch to landscape
CGPoint touch = CGPointMake([[eventTouches objectAtIndex:i] locationInView:self].x,[[eventTouches objectAtIndex:i] locationInView:self].y);
touchedScreenBegan1 = touch;
[self setNeedsDisplay];
}
if ([allTouches count] > 1) {
if ([eventTouches objectAtIndex:i] == [allTouches objectAtIndex:1]) {
//Rotated touch to landscape
CGPoint touch = CGPointMake([[eventTouches objectAtIndex:i] locationInView:self].x,[[eventTouches objectAtIndex:i] locationInView:self].y);
touchedScreenBegan2 = touch;
}
}
}
//CGPoint location = [touch locationInView:self];
// tell the view to redraw
}
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event{
NSArray* allTouches = [touches allObjects];
NSArray* eventTouches = [[event allTouches] allObjects];
for (int i = 0; i < [eventTouches count]; i +=1) {
if ([eventTouches objectAtIndex:i] == [allTouches objectAtIndex:0]) {
//Rotated touch to landscape
CGPoint touch = CGPointMake([[eventTouches objectAtIndex:i] locationInView:self].x,[[eventTouches objectAtIndex:i] locationInView:self].y);
touchedScreenMoved1 = touch;
}
if ([allTouches count] > 1) {
if ([eventTouches objectAtIndex:i] == [allTouches objectAtIndex:1]) {
//Rotated touch to landscape
CGPoint touch = CGPointMake([[eventTouches objectAtIndex:i] locationInView:self].x,[[eventTouches objectAtIndex:i] locationInView:self].y);
touchedScreenMoved2 = touch;
}
}
}
//CGPoint location = [touch locationInView:self];
// tell the view to redraw
}
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
NSArray* allTouches = [touches allObjects];
NSArray* eventTouches = [[event allTouches] allObjects];
for (int i = 0; i < [eventTouches count]; i +=1) {
if ([eventTouches objectAtIndex:i] == [allTouches objectAtIndex:0]) {
//Rotated touch to landscape
CGPoint touch = CGPointMake([[eventTouches objectAtIndex:i] locationInView:self].x,[[eventTouches objectAtIndex:i] locationInView:self].y);
touchedScreenEnded1 = touch;
}
if ([allTouches count] > 1) {
if ([eventTouches objectAtIndex:i] == [allTouches objectAtIndex:1]) {
//Rotated touch to landscape
CGPoint touch = CGPointMake([[eventTouches objectAtIndex:i] locationInView:self].x,[[eventTouches objectAtIndex:i] locationInView:self].y);
touchedScreenEnded2 = touch;
}
}
}
//CGPoint location = [touch locationInView:self];
// tell the view to redraw
}
And finally replace the initWithCoder method with this:
//The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:
- (id)initWithCoder:(NSCoder*)coder {
if ((self = [super initWithCoder:coder])) {
// Get the layer
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
eaglLayer.opaque = YES;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
if (!context || ![EAGLContext setCurrentContext:context]) {
[self release];
return nil;
}
CGRect rect = [[UIScreen mainScreen] bounds];
// Set up OpenGL projection matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthof( 0, rect.size.width, 0, rect.size.height, -1, 1 );
glMatrixMode(GL_MODELVIEW);
glViewport(0, 0, rect.size.width, rect.size.height);
// Initialize OpenGL states
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glDisable(GL_DEPTH_TEST);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND_SRC);
glEnableClientState(GL_VERTEX_ARRAY);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
testSprite = [[Image alloc] initWithImage:[UIImage imageNamed:@"Npc 1.png"]];
movingThings = [NSMutableArray new];
for (int i = 0; i < 300; i ++) {
Sprite* toAdd = [[Sprite new] initWithImage:testSprite position:CGPointMake(rand()%320, rand()%480)];
[movingThings addObject:toAdd];
}
touchedScreen1 = CGPointMake(-1, -1);
touchedScreen2 = CGPointMake(-1, -1);
updateScreen = TRUE;
middleScreen = CGPointMake((177 - 46/2)*2,(160 - 46/2)*2);
gameTimer = [NSTimer scheduledTimerWithTimeInterval:(float)1/60 target:self selector:@selector(mainGameLoop) userInfo:nil repeats:YES];
screenDimensions = CGPointMake([self bounds].size.height, [self bounds].size.width);
}
return self;
}
Sorry about that, didn't stop to think of differently oriented games.
-Gan
In your application load method you gotta configure the accelerometer:
[self configureAccelerometer];
-Gan
int x = 5, y = 12, ratio; ratio =y / x;
it said that ratio would be 2 instead of 2.4 does the compiler estimate, or does it just plain drop the factions? Also can a block of code like this exist? Also I thought variables had to be predefined in .h files and executed in .m files?
Loading/* initialize random seed: */
srand ( time(NULL) );
Anywhere Else//Get a random number, can be 0,1,2,3 or 4
int randomNumber = rand()%5;
what does that do? The individual parts. The way I've learn things is taking them apart from the inside. Is time(NULL) a main() function. Also what happens to the variables inside the parenthesis, ie. NULL
time() is a C function. time(null) gets the number of seconds since Jan 1 1970.
NULL means nothing. So you give the function nothing.
And how do you program an IF THEN statement.
int test = (rand()%2)+1;
if (test == 1) {
//Do Stuff
} else if (test == 2) {
//Do Stuff
}
Also what coding languages can you use in Object-C and howdy you incorporate them into your game. And how do you see the internal structures of main() function thingys
You can use C and C++ with Objective-C. To find functions, either Google or search the Xcode documentation.
also what the heck does void mean?
Void means that the function returns nothing.
- (void)stuff {
//stuff
}
- (void)awakeFromNib {
[self stuff];
}
If you want the function to return something you can do:
- (int)stuff {
//stuff
return 5;
}
- (void)awakeFromNib {
int testNum = [self stuff];
}
Also what the heck is a argument. The document keeps referring to it, and I'm not quite sure what it is.
The argument is the variable you're putting in the function.
int myVar = 5;
[self doStuff: myVar];
myVar is the argument cause you're putting it in a function so the function can use it.
Here's an example of a delegate .h:
#import <UIKit/UIKit.h>
@interface AppDelegate : NSObject <UIApplicationDelegate> {
NSString* name;
BOOL soundOption;
}
@property (nonatomic, retain) NSString* name;
@property (nonatomic) BOOL soundOption;
@end
Top of delegate .m file:
#import "AppDelegate.h"
@implementation QAppDelegate
@synthesize name,soundOption;
That makes 2 global variables, name and soundOption.
To use them in other classes you put this in the top of the .m:
#import "AppDelegate.h"
AppDelegate *delegate;
And this in the loading of that class:
delegate = [[UIApplication sharedApplication] delegate];
Then in that class you can access those variable by delegate.soundOption or delegate.name.
UIImage* cow = [UIImage imageNamed:@"cow.png"];
[cow retain];
UIImageView* sprite = [[UIImageView alloc] init];
sprite.image = cow:
[myView addSubview:sprite];
sprite.center = CGPointMake(50,50);
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
// Set the view controller as the window's root view controller and display.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
UIImage* player = [UIImage imageNamed:@"Sprite.gif"];
UIImageView* Sprite = [[UIImageView alloc] initWithImage:player];
[viewController addSubveiw:Sprite]; /*****problematic code*****/
Sprite.center = CGPointMake(50, 50);
return YES;
}
Without the line marked problematic code it open and showed a blank grey screen. When I put that in, it says the build was successful, and then opens, and immediately crashes.
AdventureViewController.h//
// AdventureViewController.h
// Adventure
//
// Created by Kurt Manion on 12/10/11.
// Copyright 2011 __Compleatly_Coded__. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface AdventureViewController : UIViewController {
//I like to leave the first letter lowercase.
//I have uppercase for class names
NSTimer* gameTimer;
CGPoint location;
BOOL touching;
UIImageView* hero;
UIImageView* stage;
}
- (void) makeTimer;
- (void) movehero;
/*
Unnecessary. Only use if another class needs to acess these variables
@property (nonatomic, retain) NSTimer* GameTimer;
@property (nonatomic, readwrite) CGPoint Location;
*/
@end
AdventureViewController.m//
// AdventureViewController.m
// Adventure
//
// Created by Kurt Manion on 12/10/11.
// Copyright 2011 __Compleatly_Coded__. All rights reserved.
//
#import "Adventure_Prefix.pch"
#import "AdventureViewController.h"
@implementation AdventureViewController
/*
@synthesize GameTimer;
@synthesize Location;
*/
#pragma mark -
#pragma mark Touches
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSSet* allTouches = [event allTouches];
UITouch* touch = [[allTouches allObjects] objectAtIndex:0];
CGPoint touchpoint = [touch locationInView:self.view];
touching = YES;
touchpoint.x = [touch locationInView:self.view].y;
touchpoint.y = 320 - [touch locationInView:self.view].x;
location = touchpoint;
NSLog(@"touch at location:%@",NSStringFromCGPoint(location));
}
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
//[GameTimer invalidate];
touching = NO;
//NSLog(@"Touches ended");
}
#pragma mark -
#pragma mark CustomInitalizer
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
touching = NO;
[self makeTimer];
stage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"stage1.png"]];
hero = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Sprite.png"]];
[self.view addSubview:stage];
[self.view addSubview:hero];
//[self.view insertSubview:Stage atIndex:0];
//[self.view insertSubview:Hero atIndex:1];
Stage.center = CGPointMake(480/2,320/2);
Hero.center = CGPointMake(480/2,320/2);
/*
Allocating automatically retains.
[Sprite retain];
[Hero retain];
[Stage1 retain];
[Stage retain];
*/
}
return self;
}
- (void)dealloc {
[super dealloc];
[GameTimer release];
}
#pragma mark -
#pragma mark SetUpTimer
- (void) makeTimer {
NSLog(@"making timer");
gameTimer = [NSTimer scheduledTimerWithTimeInterval:0.2
target:self
selector:@selector(movehero)
userInfo:nil
repeats:YES];
}
- (void) movehero {
if (touching == YES)
{
NSLog(@"entering move hero");
NSLog(@"%@",NSStringFromCGPoint(hero.center));
//CGPoint newCenter = Hero.center;
//What is MVM? I assume movement speed
//I'd suggest declaring it as a var or using a number
int MVM = 5;
if (location.x >= 240) {NSLog(@"touch at top"); hero.center = CGPointMake(hero.center.x - MVM, hero.center.y);}
if (location.x <= 80) {NSLog(@"touch at bottom");hero.center = CGPointMake(hero.center.x + MVM, hero.center.y);}
if (location.y >= 360) {NSLog(@"touch at right");hero.center = CGPointMake(hero.center.x, hero.center.y + MVM);}
if (location.y <= 120) {NSLog(@"touch at left");hero.center = CGPointMake(hero.center.x, hero.center.y - MVM);}
//hero.center=newCenter;
/*
Already in the view, don't need to re-insert
[self.view insertSubview:Hero atIndex:1];
*/
//NSLog(@"moving to:%@", NSStringFromCGPoint(newCenter));
}
}
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
#pragma mark -
#pragma mark CustomRules
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
/*
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
*/
/*
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
*/
@end
Cleaned up your code, might have fixed up some bugs. Can't test yet.
so yeah yadayda... code defication...
#import "Unbeatable_Prefix.pch"
@interface Sprite : NSObject {
UIImage* Image;
UIImageView* Sprite;
CGPoint Location;
}
@property (retain, nonatomic) UIImage* Image;
@property (retain, nonatomic) UIImageView* Sprite;
@property (readwrite, nonatomic) CGPoint Location;
+(void) move:(CGPoint) newPoint; //to be used by the walking and jumping function
-(void) initialize:(stype)spriteType;
@end
#import "Sprite.h"
@implementation Sprite
@synthesize Image;
@synthesize Sprite;
@synthesize Location;
+(void) move:(CGPoint) newPoint
{
self.Location = newPoint; /***** error *****/
}
-(void) initialize:(stype)spriteType
{
switch (spriteType) {
case PLAYER:
break;
case MONSTER:
break;
case ENTITY:
break;
case STAGE:
break;
default:
break;
}
}
@end
Accessing unknown setLocation method.
Object cannot be set - either readonly prop. or no setter found
#import "Unbeatable_Prefix.pch"
@interface Sprite : NSObject {
UIImage* Image;
UIImageView* Sprite;
CGPoint Location;
}
@property (retain, nonatomic) UIImage* Image;
@property (retain, nonatomic) UIImageView* Sprite;
@property (assign) CGPoint Location;
-(void) move:(CGPoint) newPoint; //to be used by the walking and jumping function
-(void) initialize:(stype)spriteType;
@end
#import "Sprite.h"
@implementation Sprite
@synthesize Image,Sprite,Location;
-(void) move:(CGPoint) newPoint
{
self.Location = newPoint; /***** error *****/
}
-(void) initialize:(stype)spriteType
{
switch (spriteType) {
case PLAYER:
break;
case MONSTER:
break;
case ENTITY:
break;
case STAGE:
break;
default:
break;
}
}
@end
Try that.
I've got two problems. One my method marked problematic code would execute, and there's an uncaught exception: NSInternalInconsistencyException from UnbeatableViewController.xib. The problem triggers, when the program tries to 'makekeyandvisible'
I've isolated the problems to those areas, but I can't for the life of me even comprehend what I did wrong.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//initialize the viewController and spriteController
NSLog(@"delegate");
self.viewController = [[UnbeatableViewController alloc] initWithNibName:@"UnbeatableViewController.xib" bundle:[NSBundle mainBundle]];
[[self.viewController sController] init:FIELD]; /***** problematic *****/
NSLog(@"end delegate");
// Set the view controller as the window's root view controller and display.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}