spritebuilder / SpriteBuilder

Objective-C Game Development Suite
http://www.spritebuilder.com/
Other
740 stars 291 forks source link

Without access on physics options of a Sprite that's a child of PhysicsNode #777

Open lucasglobal opened 10 years ago

lucasglobal commented 10 years ago

screen shot 2014-08-13 at 0 14 16

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.

LearnCocos2D commented 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.

lucasglobal commented 10 years ago

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.

MikeMJ commented 10 years ago

@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?

lucasglobal commented 10 years ago

It would be good that when we select that the CCBFile enables physics,it automatically turns itself on a physics node.

LearnCocos2D commented 10 years ago

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.

LearnCocos2D commented 10 years ago

Here's a visual example, a chain.ccb added to a level which contains the physics node:

screen shot 2014-10-04 at 19 21 15 (root node does not have physics enabled, all other nodes do)

screen shot 2014-10-04 at 19 22 02 (ccphysicsnode has container node (chains & ropes) without physics enabled, containing chains etc which reference chain.ccb but do not have physics enabled themselves)

MikeMJ commented 10 years ago

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.

LearnCocos2D commented 10 years ago

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.

screen shot 2014-10-08 at 10 55 25

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)
MikeMJ commented 10 years ago

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 .

taycaldwell commented 9 years ago

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.

LearnCocos2D commented 9 years ago

exactly :)