Guest User

Untitled

a guest
Jul 16th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. /**
  2. * @private
  3. * returns the stage point relative to the render canvas
  4. */
  5. private function canvasPointFor(stageX:Number, stageY:Number):Point {
  6. _stagePt.x = stageX;
  7. _stagePt.y = stageY;
  8.  
  9. return _mcr.renderCanvas.globalToLocal(_stagePt);
  10. }
  11.  
  12. /**
  13. * @private
  14. * converts a mouse event point to screen coordinates
  15. */
  16. private function pointInWorld( event:MouseEvent ):Vector3D {
  17. _halfPoint.x = _mcr.config.tileWidth * 0.5;
  18. _halfPoint.y = -_mcr.config.tileHeight * 0.5;
  19.  
  20. return positionMap.mapToWorld(
  21. canvasPointFor(event.stageX, event.stageY)
  22. .add(view.viewport.topLeft)
  23. .add(_halfPoint));
  24. }
  25.  
  26. /**
  27. * @private
  28. * converts a point to a tile position
  29. */
  30. private function tileInWorld( event:MouseEvent ):Vector3D {
  31. return positionMap.mapWorldToTile(pointInWorld(event));
  32. }
Add Comment
Please, Sign In to add comment