@MikeSz thats right. But currently its not as "clean" as it should be.
@all:
- (CGPoint)convertToNodeSpace:(CGPoint)worldPoint
{
return CGPointApplyAffineTransform(ccpMult(worldPoint,CC_CONTENT_SCALE_FACTOR()), [self worldToNodeTransform]);
}
is a good start put the problems go on. It also has effects on
- (CGPoint)convertToNodeSpaceAR:(CGPoint)worldPoint
{
CGPoint nodePoint = [self convertToNodeSpace:worldPoint];
return ccpSub(nodePoint, anchorPointInPixels_);
}
what should be
- (CGPoint)convertToNodeSpaceAR:(CGPoint)worldPoint
{
CGPoint nodePoint = [self convertToNodeSpace:worldPoint];
return ccpSub(nodePoint, ccpMult(anchorPointInPixels_,CC_CONTENT_SCALE_FACTOR()));
}
And
- (CGPoint)convertToWorldSpaceAR:(CGPoint)nodePoint
{
nodePoint = ccpAdd(nodePoint, ccpMult(anchorPointInPixels_,1.0f/CC_CONTENT_SCALE_FACTOR()));
return [self convertToWorldSpace:nodePoint];
}
- (CGPoint)convertTouchToNodeSpace:(UITouch *)touch
{
CGPoint point = [touch locationInView: [touch view]];
point = [[CCDirector sharedDirector] convertToGL: ccpMult(anchorPointInPixels_,1.0f/CC_CONTENT_SCALE_FACTOR())];
return CGPointApplyAffineTransform(point, [self worldToNodeTransform]);
}
- (CGPoint)convertTouchToNodeSpaceAR:(UITouch *)touch
{
CGPoint point = [touch locationInView: [touch view]];
point = [[CCDirector sharedDirector] convertToGL: point];
point = ccpAdd(point, ccpMult(anchorPointInPixels_,1.0f/CC_CONTENT_SCALE_FACTOR()));
return CGPointApplyAffineTransform(point, [self worldToNodeTransform]);
}
They get even more complicated since convertToGL works in points and with the current version everything would be converted again....
@riq:
What about using own data types for points and pixels.
CCPixel and CCPoint ?
The advantage would be that the compiler warns if somebody mixed both types. You will have to explicitly use a function to transfer one into the other.