Check for 0 length in CCPoint::normalize()

This commit is contained in:
Adrien Béraud 2013-05-07 02:59:38 +10:00
parent 49474f5194
commit f71798a35b
1 changed files with 2 additions and 0 deletions

View File

@ -170,6 +170,8 @@ public:
@since v2.1.4
*/
inline CCPoint normalize() const {
float length = getLength();
if(length == 0.) return CCPoint(*this);
return *this / getLength();
};