# Determining Click Position of 2D perspective board

This topic is 2609 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey all,

I'm messing around with Flash and making a little chess game. I need to determine which box on the board the user has clicked on so that I can move pieces around. I've thought of two possible solutions to this.

1) Treat each box on the board as an individual sprite and add a click event listener to each box.

2) Based on the dimensions of the board and the mouse coordinates, use a bit of math to determine what box the mouse is over.

I'm thinking number 2 is a better solution then to have 64 (8X8) individual sprites with individual event listeners. The problem I'm facing is that the board is a perspective board, meaning to achieve the illusion of depth the dimensions of the board are warped.

It seems like the perspective illusion is accomplished by each column of the board having a unique slope to it, the leftmost column has the steepest negative slope while the center column has a slope of 1 and the rightmost column has the highest positive slope.

Anyone have any suggestions on how to tackle this problem?
Thanks!

##### Share on other sites

It seems like the perspective illusion is accomplished by each column of the board having a unique slope to it, the leftmost column has the steepest negative slope while the center column has a slope of 1 and the rightmost column has the highest positive slope.

To me this sounds like you are using some "hand-created" algorithm that mimics proper 3D perspective projection.

I would try to represent that 3D->2D mapping as perspective projection. Perhaps something similar to this. After you have written down the perspective projection mapping, you can invert that mapping to produce the point on the original perspective-skewed rectangle.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 11
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633721
• Total Posts
3013532
×