Skip to content

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

Closed
wants to merge 1 commit into from

Conversation

luisparravicini
Copy link
Contributor

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

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);

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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).

Copy link
Contributor

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.

Copy link
Contributor

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

@litefeel
Copy link

Do not change API of cocos2dx in all language.

@cocosQA
Copy link

cocosQA commented Apr 29, 2014

Dear luisparravicini:
We have created a new branch 'v3' to replace branch 'develop', and this PR has been moved from 'develop' branch to 'v3' branch, the new PR is #6480
The old 'develop' branch will be deleted soon, and this PR will be closed accordingly.

@minggo minggo closed this Apr 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants