Skip to content
Browse files

fixed #1463 check arguments is null for Geometry

  • Loading branch information...
1 parent a0389fe commit 8a904dd632fdc9026851702573b832ca6a539194 @dingpinglv dingpinglv committed Dec 3, 2012
Showing with 7 additions and 1 deletion.
  1. +6 −0 cocos2d/cocoa/CCGeometry.js
  2. +1 −1 cocos2d/sprite_nodes/CCSprite.js
View
6 cocos2d/cocoa/CCGeometry.js
@@ -103,6 +103,8 @@ Object.defineProperties(cc, {
* Constructor
*/
cc.pointEqualToPoint = function (point1, point2) {
+ if (!point1 || !point2)
+ return false;
return ((point1.x == point2.x) && (point1.y == point2.y));
};
@@ -172,6 +174,8 @@ cc.SizeZero = function () {
* Constructor
*/
cc.sizeEqualToSize = function (size1, size2) {
+ if (!size1 || !size2)
+ return false;
return ((size1.width == size2.width) && (size1.height == size2.height));
};
@@ -267,6 +271,8 @@ cc.RectZero = function () {
* Constructor
*/
cc.rectEqualToRect = function (rect1, rect2) {
+ if(!rect1 || !rect2)
+ return false;
return ((cc.Point.CCPointEqualToPoint(rect1.origin, rect2.origin)) &&
(cc.Size.CCSizeEqualToSize(rect1.size, rect2.size)));
};
View
2 cocos2d/sprite_nodes/CCSprite.js
@@ -1632,7 +1632,7 @@ cc.Sprite = cc.Node.extend(/** @lends cc.Sprite# */{
} else {
if (this._texture != texture) {
if (texture instanceof HTMLImageElement) {
- if(cc.rectEqualToRect(this._rect,cc.RectZero()))
+ if(!this._rect || cc.rectEqualToRect(this._rect,cc.RectZero()))
this._rect = cc.rect(0, 0, texture.width, texture.height);
this._texture = texture;
this._originalTexture = texture;

0 comments on commit 8a904dd

Please sign in to comment.
Something went wrong with that request. Please try again.