cocos2d-objc icon indicating copy to clipboard operation
cocos2d-objc copied to clipboard

Add support for empty CCNode:s to CCSpriteBatchNode

Open vlidholt opened this issue 13 years ago • 10 comments

As we will not be able to finish a new renderer in time for the 3.0 release, this would be a great feature to add.

The idea is that the CCSpriteBatchNode should support not only CCSprite, but also CCNode (not sub-classes thereof). The CCNode's in this case are only used for positioning. This improvement adds more flexibility when creating more complex animations and positioning (e.g. for animations created with SpriteBuilder).

vlidholt avatar Nov 27 '13 02:11 vlidholt

I am pretty sure I have tried this some time back, and got it to work, so let me have a look at it.

Birkemose avatar Dec 01 '13 10:12 Birkemose

"As we will not be able to finish a new renderer in time for the 3.0 release,"

This doesn't seem strange to anyone?

I'm not familiar with a release timetable. Is there an apportable client waiting for the 3.0 release for a project that's driving the release schedule and features/functionality determinants?

On Sun, Dec 1, 2013 at 2:13 AM, Birkemose [email protected] wrote:

I am pretty sure I have tried this some time back, and got it to work, so let me have a look at it.

— Reply to this email directly or view it on GitHubhttps://github.com/cocos2d/cocos2d-iphone/issues/400#issuecomment-29570885 .

dissidently avatar Dec 01 '13 12:12 dissidently

I can not comment on Apportables marketing strategy, but I personally voted in favour of releasing V3 with some of the key features missing, simply to get something out the door. If we would have waited until everything was done, it would probably have been a mid 2014 release.

I think it was important to send a signal to the community, that we are working hard to keep cocos2d up to date, even if it results in V3 not being complete. The idea is, to update much more frequently than previously, so ex. 3.1 (probably including a lot of the new renderer) should follow first quarter 2014.

Birkemose avatar Dec 02 '13 09:12 Birkemose

Have added this and will submit later on for review.

cocojoe avatar Dec 02 '13 16:12 cocojoe

From an observers point of view it looks much like piecemeal and incidental concurrent developmental discoveries and aesthetic code considerations are leading the design. Would any of you build anything else in this manner?

Sent from my iPad

On Dec 2, 2013, at 5:17 PM, Birkemose [email protected] wrote:

I can not comment on Apportables marketing strategy, but I personally voted in favour of releasing V3 with some of the key features missing, simply to get something out the door. If we would have waited until everything was done, it would probably have been a mid 2014 release.

I think it was important to send a signal to the community, that we are working hard to keep cocos2d up to date, even if it results in V3 not being complete. The idea is, to update much more frequently than previously, so ex. 3.1 (probably including a lot of the new renderer) should follow first quarter 2014.


Reply to this email directly or view it on GitHub.

dissidently avatar Dec 02 '13 22:12 dissidently

Well this is getting really off topic, but the options considered were to either:

  • Delay v3 until every change that the team wanted to make was complete. No engine developer will every be completely happy with what they've made, and "complete" might be never.
  • Release the features we have developed and push off the bigger rendering changes until 3.1. So far everybody has ideas they want to try, but nobody even has a working prototype of what the new renderer would look like.

Trying to completely revamp the render while also implementing all the other features we've done simply was not possible. Apportable's encouragement is largely responsible for when we put out the alpha, but it was the team's decision to split the renderer off into a separate version. Sponsorship and funding aside, we can't keep the community interested in Cocos2D forever if we don't keep some momentum up.

Honestly, decisions like that are what keep software projects from turning completely into vaporware. While this particular issue may be a band-aid, it helps keep things running smoothly enough so that we have time to come up with something better.

slembcke avatar Dec 02 '13 22:12 slembcke

Hi guys!

I know that issue is closed, but I couldn't make it work and had to make some changes in CCSpriteBatchNode.m https://github.com/kmuzykov/cocos2d-iphone/commit/e7f8b543f35fbda6555bb13a0bd15e3a4e04c89f

Don't know how this will work with the rest of the code, I've only made a few test with empty CCNode and 2 sprites in it, and a separate sprite, but without that change it didn't draw the sprites which are children of that empty CCNode.

Hope this helps in any way. Thanks!

kmuzykov avatar Dec 05 '13 14:12 kmuzykov

Thanks, when I was testing I was using CCNode parent/children position tracking from moving the batchNode as the test case. However I suppose? no reason you shouldn't be able to add child sprites of the ccnode to the batchNode assuming they are using the same atlas (existing functionality only checks the node added via addChild).

You just need to loop children at the top start of the method but exclude nodes from being added as sprites would.

for(CCSprite* child in sprite.children) [self appendChild:child];

if([sprite isMemberOfClass:[CCNode class]])
    return;

Let me check a couple of bits.

On 5 December 2013 14:58, Kirill Muzykov [email protected] wrote:

Hi guys!

I know that issue is closed, but I couldn't make it work and had to make some changes in CCSpriteBatchNode.m kmuzykov@e7f8b54https://github.com/kmuzykov/cocos2d-iphone/commit/e7f8b543f35fbda6555bb13a0bd15e3a4e04c89f

Don't know how this will work with the rest of the code, I've only made a few test with empty CCNode and 2 sprites in it, and a separate sprite, but without that change it didn't draw the sprites which are children of that empty CCNode.

Hope this helps in any way. Thanks!

— Reply to this email directly or view it on GitHubhttps://github.com/cocos2d/cocos2d-iphone/issues/400#issuecomment-29903984 .

Martin

cocojoe avatar Dec 05 '13 16:12 cocojoe

Thanks, that will be even better! I have a case when I want to add a subclass of CCNode with several children sprites and the code to manage them, this will solve this.

Can't wait for next stable preview or even beta!

kmuzykov avatar Dec 06 '13 08:12 kmuzykov

Having tested this thoroughly things tend to break down with z ordering as hierarchy complexity increase, not to mention odd issues in iOS >=7, batch node support was always a bit of a hack and this was basically another hack bending the will of CCNode to be more like a CCSprite. So I am going to revert these changes as it just doesn't feel reliable enough to recommend. I have reviewed this with Lars. All of this will be redundant anyway with the new rendering code in the not too distant future.

For now I'm adding a method to create a non rendered control sprite that will do the job nicely.

cocojoe avatar Dec 10 '13 22:12 cocojoe