Posted By

sidneydekoning on 06/11/09


Tagged

object math mod as3 Modulo snap


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

szoftverhiba
liamr
arpo
toxin20
Pingpongbal
TrentSkunk


Using modulo to snap an object


 / Published in: ActionScript 3
 

  1. // Snap object depending on the snapToSize
  2. // Can be used for window dragging or in games etc.
  3. // if the side of my square in my grid is 250, the snapToSize parameter would be 250.
  4. // If it is 100, the snapToSize parameter would be 100.
  5.  
  6. var snapToSize:int = 5;
  7.  
  8. snapClip_mc.x = mouseX - mouseX % snapToSize;
  9. snapClip_mc.y = mouseY - mouseY % snapToSize;

Report this snippet  

You need to login to post a comment.