Are you sure you should be calling parseInt
? In general one should avoid unnecessary conversions from numbers to strings or vice-versa. Just call Math.floor
.
Also, it might be easier if you didn’t set Node.locationSpot at all, so that the location would just be at the top-left corner, and so that the location and the position are the same value.