Reputation: 2002
I have this layer that called Gameplay layer that itself is the handler of the Tilemap in game, and to this layer I add the player and add the player to the controlLayer so the player class can be controlled by the player. Then I add the controlLayer as child of this class (Gameplay layer) the problem is now that the coordinates for the touches (ccTouchesBegan...) now becomes in the same coordinates as the tileMap width and height. But I want the controlLayer to be independent and have the normal 480x320 coordinates, how can I fix this?
controlLayer = [[DigGameControlLayer alloc]initWithObjectForPlayerControl:player];
[self addChild:controlLayer];
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
for (UITouch *t in touches) {
CGPoint touchLocation = [self convertTouchToNodeSpace:t];
Upvotes: 1
Views: 110
Reputation: 2002
I´m gonna answer my own question, using the LocationInView of the touch´s own view works well enough
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
for (UITouch *t in touches) {
CGPoint touchLocation = [t locationInView:t.view];
Upvotes: 1