View Single Post
  #2  
Old 10-26-2011, 06:20 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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.
__________________
Quote:
Reply With Quote