Sets this this vector to point in the specified integer direction (0-3), corresponding to multiples of 90 degree rotation * @param {number} [direction] * @param {number} [length] * @return {Vector2}
(direction, length=1)
| 759 | * @param {number} [length] |
| 760 | * @return {Vector2} */ |
| 761 | setDirection(direction, length=1) |
| 762 | { |
| 763 | ASSERT_NUMBER_VALID(direction); |
| 764 | ASSERT_NUMBER_VALID(length); |
| 765 | direction = mod(direction, 4); |
| 766 | ASSERT(direction===0 || direction===1 || direction===2 || direction===3, |
| 767 | 'Vector2.setDirection() direction must be an integer between 0 and 3.'); |
| 768 | |
| 769 | this.x = direction%2 ? direction-1 ? -length : length : 0; |
| 770 | this.y = direction%2 ? 0 : direction ? -length : length; |
| 771 | return this; |
| 772 | } |
| 773 | |
| 774 | /** Returns the integer direction of this vector, corresponding to multiples of 90 degree rotation (0-3) |
| 775 | * @return {number} */ |
no test coverage detected