Greetings,
I have run into a problem that is reproduced by the following code. The issue is that if I click on the screen I get the correct location, but if I swipe (anywhere) I get 160x240. The code below can be dropped into a Cocos2d template's HelloWorldScene.mm and will output the coords to the console.
Can someone tell me if this is a bug or if I am missing something?
Thanks.
Here is the code that reproduces the problem (I also see the same issue with the CCTouchXXX as well as the CCTouchesXXX methods):
// Import the interfaces
#import "HelloWorldScene.h"
// HelloWorld implementation
@implementation HelloWorld
+(id) scene
{
// 'scene' is an autorelease object.
CCScene *scene = [CCScene node];
// 'layer' is an autorelease object.
HelloWorld *layer = [HelloWorld node];
// add layer as a child to scene
[scene addChild: layer];
// return the scene
return scene;
}
// initialize your instance here
-(id) init
{
if( (self=[super init])) {
// enable touches
self.isTouchEnabled = YES;
// enable accelerometer
self.isAccelerometerEnabled = YES;
CGSize screenSize = [CCDirector sharedDirector].winSize;
CCLOG(@"Screen width %0.2f screen height %0.2f",screenSize.width,screenSize.height);
}
return self;
}
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
for( UITouch *touch in touches ) {
CGPoint location = [touch locationInView: [touch view]];
CCLOG(@"BEGAN location is %.2f x %.2f", location.x,location.y);
}
}
// on "dealloc" you need to release all your retained objects
- (void) dealloc
{
// don't forget to call "super dealloc"
[super dealloc];
}
@end