I am doing some r &d in cocos2d.I have one backgroundLayer and add one sprite in that layer.
In touches Moved i changed the sprite position to current touch position.If background layer is not scaling that means backgroundLayer scale is 1 ,the code is run perfectly (simply set the touch position to sprite position).if i scaling the backgroundLayer i have the problem sprite doesn’t move touch position ..please any one help me.
Here is my code:
layer1=[CCLayer node];
[self addChild:layer1];
layer1.scale=2;
iconImg=[CCSprite spriteWithFile:@"Icon-72.png"];
iconImg.position=ccp(512,384);
[layer1 addChild:iconImg];
In Touches Moved
iconImg.position=tchLocation;
My problem is after scaling the backgroundLayer how to find the touch position according to the background layer position..any one guide me…
How do you calculate your tchLocation?
It should work with:
Where touch is your UITouch.