Skip to content

Add SkeletonAnimation and GLProgram to the list of extendable classes. #1132

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

Merged
merged 7 commits into from
Feb 5, 2015
Merged

Conversation

IgorMats
Copy link
Contributor

Hi.

In my case it was very useful to add SkeletonAnimation and GLProgram to the list of extendable classes...

For GLProgram extend I've added only cc.GLProgram.extend = cc.Class.extend, but it was very hard to extend SkeletonAnimation class:

This branch:

  1. I have added SkeletonAnimation to the list of extendable classes;

Cocos2d-x branch:

  1. I've made empty constructor of SkeletonAnimation visible (public);
  2. I've added initWithFiles method which will be called from:
  3. I've added _ctor function.

What do you think about it?

Thank you!

@IgorMats
Copy link
Contributor Author

Build was failed because cocos2d-x branch need to merge this pull request: cocos2d/cocos2d-x#9199

@@ -241,3 +241,5 @@ cc.ScrollView.extend = cc.Class.extend;
cc.TableView.extend = cc.Class.extend;
cc.TableViewCell.extend = cc.Class.extend;

sp.SkeletonAnimation.extend = cc.Class.extend;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create frameworks/js-bindings/bindings/script/jsb_spine.js file and put all related scripts there, for package division purpose we need to separate scripts for different modules

@pandamicro
Copy link
Contributor

Please do not commit anything under frameworks/js-bindings/bindings/auto/. All auto bindings will be generated automatically by our cocos robot account.

@IgorMats
Copy link
Contributor Author

Hi @pandamicro.

Please take a look at the fixed implementation.

Thanks.

@pandamicro
Copy link
Contributor

It should be ok, can you add a test case for it ? We can't merge any feature without a test case

@IgorMats
Copy link
Contributor Author

Yeah, I will do it ASAP.

@pandamicro
Copy link
Contributor

As it won't work unless the C++ API get bound, I'm not sure it worth your time now to create a test case

@IgorMats
Copy link
Contributor Author

@pandamicro, okay. I will try to send pull request to the spine runtimes repository first.

@IgorMats
Copy link
Contributor Author

@pandamicro, or maybe you can suggest how we can solve this on javascript level? Because I not understand yet how we can bind class with protected empty constructor.

@pandamicro
Copy link
Contributor

In fact, we used CC_CONSTRUCTOR_ACCESS macro for constructors and init functions, the value is protected in Cocos2d-x, but public in Cocos2d-JS

@IgorMats
Copy link
Contributor Author

It's ok, but current version of SkeletonAnimation.h in Cocos2d-x is using protected instead of CC_CONSTRUCTORS_ACCESS: https://github.com/cocos2d/cocos2d-x/blob/v3/cocos/editor-support/spine/SkeletonAnimation.h. Is this a mistake?

@pandamicro
Copy link
Contributor

I think that Spine guys haven't taken account of JSB needs when they implement it.

@IgorMats
Copy link
Contributor Author

Sure! Therefore, we return to the previous question.

@pandamicro
Copy link
Contributor

I think you mean: how we can bind class with protected empty constructor.

We can't, all protected functions are ignored by bindings generator

@IgorMats
Copy link
Contributor Author

So it's mean that if we can't change protected to CC_CONSTRUCTOR_ACCESS we can't extend class in JSB?

Spine runtime do not accept that changes.

In that case I don't know what can I do with it.

@pandamicro
Copy link
Contributor

Can you give the link of the discussion?

@IgorMats
Copy link
Contributor Author

@pandamicro sorry, it was just my guess.

I created a pull request at spine-runtimes repo: EsotericSoftware/spine-runtimes#333 but as @NathanSweet wrote he is will travel a few weeks and can not accept any pull requests.

@IgorMats
Copy link
Contributor Author

@pandamicro

Hi. So, @NathanSweet closed my pull request. Can we move forward with my feature request? Thanks.

@pandamicro
Copy link
Contributor

Yes, I saw it, finally. I will try to sync spine runtime for Cocos2d-x tomorrow then we can finally get to this PR. Really appreciate your effort

@pandamicro
Copy link
Contributor

@IgorMats I have a question about your modification,

Why are you skipping the default initialize in both SkeletonAnimation and SkeletonRenderer ?

@IgorMats
Copy link
Contributor Author

@pandamicro I don't remember exactly. It was a too long time ago) Sorry.

@IgorMats
Copy link
Contributor Author

I think there was a some problem related to the empty constructor and priority of calling constructor, setSkeletonData and initialize methods.

@pandamicro pandamicro added this to the 3.3 milestone Feb 1, 2015
@pandamicro
Copy link
Contributor

Hi, @IgorMats I have updated Cocos2d-x with the modifications you pushed to Spine

#1438

Now can you fix the compilation issue in Travis ? I think pull the latest repo can fix it.

@IgorMats
Copy link
Contributor Author

IgorMats commented Feb 4, 2015

Hi, @pandamicro thanks. I'm alredy do it right now. I will finish ASAP.

@IgorMats
Copy link
Contributor Author

IgorMats commented Feb 4, 2015

@pandamicro ok, so build was successful. Now I will try to add some test case.

@IgorMats
Copy link
Contributor Author

IgorMats commented Feb 4, 2015

@pandamicro I tested it on our company project just now and it works like a charm for both: Android, iOS and Web.

Now, can your tell me please what kind of test I must to implement?
It should be just test of extends?

Thanks.

@pandamicro
Copy link
Contributor

Great ! You are so efficient !
You can add some test case to samples/js-tests/src/SpineTest/SpineTest.js
Now we only have one scene with two animations, if you like you can add some more if there is no issue with the copyright of the resources. For testing extend, just do it in the way you use in your project.

@pandamicro
Copy link
Contributor

If you can do it within one day, I think I can merge it into 3.3, because it's supposed to be released by the end of this week.

@IgorMats
Copy link
Contributor Author

IgorMats commented Feb 4, 2015

OK, I will do it today. Thanks.

@IgorMats
Copy link
Contributor Author

IgorMats commented Feb 4, 2015

@pandamicro sorry, but I can't do it today. Now we have some active hostilities in our country :(

@pandamicro
Copy link
Contributor

Hang in there man ! I want you to know that the cocos team are all with you !
Don't worry about the PR, I will add some test for it.
I wish the war in Ukraine will soon be finished, let Ukraine people suffer less and let's build something useful with our code !

pandamicro added a commit that referenced this pull request Feb 5, 2015
Add SkeletonAnimation and GLProgram to the list of extendable classes.
@pandamicro pandamicro merged commit 69dee37 into cocos2d:develop Feb 5, 2015
@IcePower2012
Copy link

@IgorMats 小伙子加油! Hope the world will be peace!

pandamicro added a commit to pandamicro/cocos2d-js that referenced this pull request Feb 5, 2015
pandamicro added a commit to pandamicro/cocos2d-js that referenced this pull request Feb 5, 2015
pandamicro added a commit that referenced this pull request Feb 5, 2015
#1132: Improved `_ctor` implementation and added test for extending SkeletonAnimation
@pandamicro
Copy link
Contributor

@IgorMats I added the test case and it works like a charm !
#1444

@0716wenzheng
Copy link

Everything will be ok

@kyoshiwoa
Copy link

my first message ,Good Luck for you and your family!

@IgorMats
Copy link
Contributor Author

IgorMats commented Feb 6, 2015

Oh, thank you guys! Now we have a big problem with safety, but I will try to continue work on cocos2d-js.

@pandamicro thank you for completion of my PR. I apologize that I could not finish it myself.

@pandamicro
Copy link
Contributor

It's totally ok, we really appreciate your effort on Cocos2d-JS ! Take care and be safe !

@yunfeige
Copy link

I admire you, and Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants