-
Notifications
You must be signed in to change notification settings - Fork 7.1k
CCRects converted with jsb does not create origin/size properties #4010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
JS_DefineProperty(cx, tmp, "height", DOUBLE_TO_JSVAL(v.size.height), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); | ||
JSBool ok = JS_DefineProperty(cx, tmp, "size", ccsize_to_jsval(cx, v.size), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT) && | ||
JS_DefineProperty(cx, tmp, "origin", ccpoint_to_jsval(cx, v.origin), NULL, NULL, JSPROP_ENUMERATE | JSPROP_PERMANENT); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @luisparravicini ,
We should not delete x, y, width, height
directly and use origin, size
. That will break the compatibility of JSB.
Do you have any ideas about keep the compatibility?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping x/y/height/width and adding size/origin would be exactly like what getBoundingBox() returns in js.
The thing is, (maybe because this is my first attempt at modifying cocos2d and not knowing the inner workings of it) but I don't really know why a ccrect in this case is not using size/origin.
Can you take a look at my last note on http://www.cocos2d-x.org/issues/3065#note-3 ?
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the API point of view, I think it is simpler to use x, y, width, height
directly.
Although origin
and size
are correct, the user has to type more.
So, instead of fixing CCRect
and I would fix the return value getBoundingBox()
I do not know if that can be done automatically with the bindings... if the return value is CCRect
, then return x,y,width,height
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I'm doing too many questions: if CCRects
(when used through jsb) have to return x, y, width, height
, which is what's happening now (not taking into account this pr), why not leave getBoundingBox()
as is but change in js cc._RectApplyAffineTransformIn
to just don't return origin
and size
? That's what made me create the issue and this patch in the first place (unless such a change in the API is unacceptable).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Luis.
Tomorrow I'll review our code... I'll give you a detailed answer tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this bug report about regarding this:
http://www.cocos2d-x.org/issues/3260
Do not change API of cocos2dx in all language. |
Dear luisparravicini: |
When using javascript through jsb, a call to getBoundingBox() returns an object with properties x/y/height/width and not origin/size properties.
Submitted as issue 3065
cocos2d-js-tests pull request: 231