-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
coordForPoint not working for isometric maps #10
Comments
I'm not sure exactly what you are asking here. Are you wanting something more than the (translated to world) coordinates of a given sprite? |
I would like to know the tile coordinate for the current touch. Thanks in advance. Btw : Thanks for publishing this class, it is great! |
@Nightmare82 are you scaling the map at all? If you are then you may need to factor the scaling into the touch point as well to get the appropriate response. |
No I don't scale the map. sprite.position = CGPointMake((layer.mapTileSize.width / 2.0) * (layerInfo.layerGridSize.width + col - row - 1), (layer.mapTileSize.height / 2.0) * ((layerInfo.layerGridSize.height * 2 - col - row) - 2) ); And coordForPoint uses the same calculation for all maps: - (CGPoint) coordForPoint:(CGPoint) inPoint
{
// invert y axis
inPoint.y = [self layerHeight] - inPoint.y;
int x = inPoint.x / _mapTileSize.height;
int y = (int)inPoint.y / _mapTileSize.width;
return CGPointMake(x, y);
} Shouldn't the calculation be different for isometric maps ? |
@Nightmare82 you are correct, this does not work properly and needs to be rewritten in the case of isometric maps to do the right thing. I am not an iso map expert by any means, so help would be appreciated. |
OK thanks for your answer. I currently work on another task but if I find a solution I'll let you know. |
I try to find out the tile coordinate for a world coordinate. I tried to used the coordForPoint-function but it doesn't work correctly for my isometric map. Is there a way to calculate the tile coordinate for a world coordinate on isometric maps ?
The text was updated successfully, but these errors were encountered: