Open lucasglobal opened 10 years ago
You are not supposed to activate physics on a CCBFile. The fact that you can do this right now is a bug: https://github.com/spritebuilder/SpriteBuilder/issues/427
Instead open the referenced CCB file and enable physics on the node(s) inside the referenced CCB.
Why it's a bug doing this?
Att,
Lucas Andrade Ribeiro
Em 20/08/2014, às 07:23, "Steffen Itterheim" notifications@github.com escreveu:
You are not supposed to activate physics on a CCBFile. The fact that you can do this right now is a bug.
— Reply to this email directly or view it on GitHub.
@LearnCocos2D, but activating the physics on the nodes of the CCB has no effect. Physics just doesn't work on that CCB. (As of version 1.2.1) But enabling physics of the the CCB as a whole does work. And you say it's a bug to allow setting physics properties on a CCBFile. If it's disabled totally, how are we going to make physics work?
It would be good that when we select that the CCBFile enables physics,it automatically turns itself on a physics node.
This setup should work:
Scene.ccb
-> root node
-> CCPhysicsNode
-> CCBFile (references MyNodes.ccb)
MyNodes.ccb
-> root node (physics enabled)
Or in MyNodes you can leave the root node physics disabled, but add multiple nodes with physics enabled. For instance:
MyNodes.ccb
-> root node (no physics)
-> chain1 (physics enabled)
-> chain2 (physics enabled)
-> chain3 (physics enabled)
-> chain4 (physics enabled)
Tested with v1.2 and v1.3.
Here's a visual example, a chain.ccb added to a level which contains the physics node:
(root node does not have physics enabled, all other nodes do)
(ccphysicsnode has container node (chains & ropes) without physics enabled, containing chains etc which reference chain.ccb but do not have physics enabled themselves)
Taking your first solution into consideration, I think there's one thing you're forgetting about. If the type of the CCB file is a CCNode, then there is a root node. But if it's of type CCSprite, then there's no root node and the only thing you can enable physics on is the CCSprite, which as I previously said does not work.
I can't rule out that there isn't a bug. But I do know that Sprite CCB generally works with physics enabled. Below is my player character (CCSprite root node) which has physics enabled and works fine when dragged into a level CCB as child of a CCPhysicsNode.
The setup is the same as posted earlier:
Scene.ccb
-> root node
-> CCPhysicsNode
-> CCBFile (references Player.ccb)
Player.ccb
-> root node (physics enabled - see screenshot above)
Yes, Steffen, you're right. When I tried what you said in another case, it did work. I can't find any difference between the ones that work, and the ones that don't. So my guessing is there definitely a bug that needs to be revised.
On Wed, Oct 8, 2014 at 1:57 PM, Steffen Itterheim notifications@github.com wrote:
I can't rule out that there isn't a bug. But I do know that Sprite CCB also work with physics enabled. Below is my player character (CCSprite root node) which has physics enabled and works fine when dragged into a level CCB as child of a CCPhysicsNode.
[image: screen shot 2014-10-08 at 10 55 25] https://cloud.githubusercontent.com/assets/214599/4556429/e204760a-4ec8-11e4-805f-40f777c76ea1.png
— Reply to this email directly or view it on GitHub https://github.com/spritebuilder/SpriteBuilder/issues/777#issuecomment-58328763 .
This bug still seems to exist.
@LearnCocos2D Out of curiosity - For the ball and chain example you gave, if nothing besides the chains and ball of the ccb file has physics enabled, how are you able to hook the chain the the ceiling of the other ccb file? I am trying to implement something similar, and it just falls to the ground. If I wanted to use a pivot node to attach the chain to the ceiling, I can't accomplish this with only physics enabled on chain/ball ccb items.
Edit: Nevermind I now see that having a "hook" on the chain with static physics is the way to go, instead of using a pivot node to attach a chain to a ceiling.
exactly :)
As you can see, everything looks good, except for the physics options of my cbfile(sprite) that i have to do some wrong things to activate.