
10-26-2011, 06:20 AM
|
team canada
|
 |
Join Date: Jul 2004
Location: Canada
Posts: 5,200
|
|
1. onMouseDown: Determine the tile the mouse is currently over and use it as your top-left reference point.
2. onMouseDragged: Determine the tile the mouse is currently over and use it as your bottom-right reference point.
3. onMouseUp: Do whatever with your selection.
I believe:
tile_x = mouse_x - (mouse_x % tile_width);
tile_y = mouse_y - (mouse_y % tile_height);
Will get you the top-left x and y of the tile your mouse is currently over.
% is for modulus which basically gives you the remainder from dividing a number. I.e: 20 % 16 equals 4. |
|
|