im currently trying to get touch responding in my game however although the code picks up the touch event when i try to use the hash key value for the touch it always comes in as the value 1 so when this function occurs
Code:
- (void)touchesBegan: (NSSet *)touches withEvent: (UIEvent *)event {
[touchDelegate touchesBegan:touches withEvent:event];
//when i go to use [touches hash] the value returned is always 1?
}
this baffles me and obviously i cant do anything with it, i can only assume its the way the view and window are set up, and at the moment im using someone else's engine so im not to sure what it could be exactly but i have a feeling the error is in that area. Code of how the window is as follows
Code:
//
// EAGLView.m
// Game
//
// Created by Richard Henry on 16/11/2009.
// Copyright University of Teesside 2009. All rights reserved.
//
#import "DSGLView.h"
#import "DSES1DrawContext.h"
#import "DSES2DrawContext.h"
@implementation DSGLView
+ (Class)layerClass { return [CAEAGLLayer class]; }
- (id)initWithCoder: (NSCoder*)coder {
// The GL view is stored in the nib file. When it's unarchived it's sent -initWithCoder:
if ((self = [super initWithCoder:coder])) {
// Get the layer
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
eaglLayer.opaque = YES;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
#ifdef __IPHONE_3_0
BOOL tryES2 = YES;
// Initialise a draw context
if (!tryES2 || !(drawContext = [[DSES2DrawContext alloc] init])) {
if (!(drawContext = [[DSES1DrawContext alloc] init])) { [self autorelease]; return nil; }
}
#else
// Initialise a draw context
if (!(drawContext = [[DSES1DrawContext alloc] init])) { [self autorelease]; return nil; }
#endif
}
return self;
}
- (void)layoutSubviews {
[drawContext attachFramebuffer:(CAEAGLLayer*)self.layer];
}
- (void)dealloc {
[drawContext release];
[super dealloc];
}
#pragma mark Touch handling
- (void)touchesBegan: (NSSet *)touches withEvent: (UIEvent *)event {
[touchDelegate touchesBegan:touches withEvent:event];
}
- (void)touchesMoved: (NSSet *)touches withEvent: (UIEvent *)event {
[touchDelegate touchesMoved:touches withEvent:event];
}
- (void)touchesEnded: (NSSet *)touches withEvent: (UIEvent *)event {
[touchDelegate touchesEnded:touches withEvent:event];
}
- (void)touchesCancelled: (NSSet *)touches withEvent: (UIEvent *)event {
[touchDelegate touchesCancelled:touches withEvent:event];
}
@synthesize touchDelegate;
@synthesize drawContext;
@end
ive been told initWithCoder comes with some issues.
Any suggestions?