shbli
shbli

Reputation: 571

Cocos2d and ios5 : ccTouchesBegan

My question is that, I was using this method before it was working perfectly, today am trying to do it in another project. This is the code

- (void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch* touch = [touches anyObject];
    CGPoint touchPos = [[CCDirector sharedDirector] convertToGL:[touch locationInView:[touch view]]];
    CCLOG(@"( %d , %d )",touchPos.x,touchPos.y);
}

What I'm getting is strange output the output is always similar to this ( 0 , 1081286656 )

I would love if someone could help me

Best Regards Ahmed

Upvotes: 1

Views: 1125

Answers (1)

albertamg
albertamg

Reputation: 28572

The reason for the strange output you are getting is that you are using the wrong string format specifiers. CGPoint's x and y fields are CGFloats. You need to use %f instead of %d (which is for integers).

Upvotes: 2

Related Questions