Cocos2d, Box2D Still body till input

Hey guys i have a question here, How do i create a body that will not have physic function until i press it? i have this code in my init

CCSprite *tail = [CCSprite spriteWithFile:@"Ball.jpg"]; [self addChild:tail z:1]; b2BodyDef tailBodyDef; tailBodyDef.type = b2_dynamicBody; tailBodyDef.position.Set(100/PTM_RATIO, 100/PTM_RATIO); tailBodyDef.userData = tail; tailBody = world->CreateBody(&tailBodyDef); b2CircleShape circle; circle.m_radius = 26.0/PTM_RATIO; b2FixtureDef tailShapeDef; tailShapeDef.shape = &circle; tailShapeDef.density = 1.0f; tailShapeDef.friction = 0.2f; tailShapeDef.restitution = 0.8f; tailBody->CreateFixture(&tailShapeDef); [self schedule: @selector(tick:)];

The ball will drop off the the edge of screen at the start of game, but thats not what i want. i want it to stay at the same position until i press it. is there anyway i could hold the object back until i give some input?

-------------Problems Reply------------

Haven't tried it but toggling the setActive property seems perfect.

tailBody->setActive(NO);

Check out the 'activation' section here: http://www.box2d.org/manual.html#_Toc258082973

Category:iphone Views:0 Time:2012-02-05

Related post

  • Cocos2d + Box2d or Chipmunk 2010-01-22

    OK, im trying to make an iphone version of a game i made here http://scratch.mit.edu/projects/techy/781198 is box2d or chipmunk better and where are some tutorials for each one --------------Solutions------------- I prefer Box2d - I think it is easie

  • Getting EXC_BAD_ACCESS with Cocos2d & Box2d while attempting to use DebugDraw 2011-03-03

    this thing is making me crazy! I'm experimenting with Cocos2d (0.99.5) and Box2D, and I have successfully created a scene with a layer and two bodies (actually a couple of bouncing balls). Now I would like to enable the DebugDrawing so I can see exac

  • How to start with Cocos2D Box2D? 2011-03-18

    i want to learn 2D gaming using Cocos2D/Box2D on iPhone... Gaming demands lots of things to be under the understanding before you actually dive in like physics/geomerical concepts...how to really start with it?? --------------Solutions------------- R

  • Cocos2d & Box2d dynamic lighting and shadows 2011-04-05

    I'm looking to start building an iPhone app and I was wondering if it was possible to create dynamic lighting/shadows using the Cocos2d/Box2D combo? I have worked with these before and would like to stay with them. I would like the lighting to update

  • cocos2d/box2d iPhone - Random circular paths 2011-04-27

    I am experimenting with some new ideas in Cocos2D/Box2D on iPhone. I want to animate a small swarm of fireflies moving on circular (random?) paths... the idea is that the user can capture a firefly with a net.. I have considered using gravity simulat

  • cocos2d, box2d and retina mode: give up, or try to get it to work? 2011-05-01

    I've been trying to get my box2d game to work in retina mode, and I'm running into a lot of irritating issues when running in higher-resolution mode. cocos2d renders my graphics correctly in retina mode, but I'm finding the need for hack after hack t

  • Cocos2d / Box2d CCRibbon Collision Detection 2011-06-10

    I'm developing a game on iOS w/ cocos2d+box2d as the game engine, and am trying to add a CCRibbon (wherein the points get populated with touches), that I know how to, and to get that CCRibbon's shape linked up to box2d, so when an object collides wit

  • how to add a device for the project that based on cocos2d-box2d? 2011-11-02

    I create a project based on cocos2d-box2d, when I want to debug it on a device, but it can not get the device, so what should i do?please look the picture here:http://i.stack.imgur.com/x9g2a.png but if I create a project just based on cocos2d, the de

  • the warning "'uniqueIdentifier' is deprecated" in project based on cocos2d-box2d 2011-11-08

    I create a new project based on cocos2d-box2d, and there are always 4 warning in two files, one is CLScoreServerPost.m, the code has warning is following [self addValue:[[UIDevice currentDevice] uniqueIdentifier] key:@"cc_device_id"]; and another is

  • cocos2d,box2d: coin based game: gravity on z-axis, coin floating 2011-11-28

    Now I am working on carrom like game using cocos2d + Box2d. I set world gravity(0,0)..to make gravity on z-axis. Is it proper or any other value? I set following value for coin striker body: Coin body: density = 20.0f; friction = 0.4f; restitution =

  • Joint in cocos2d-box2d in android 2012-02-22

    I am new box2d. I am working on cocos2d-box2d in android. I am trying to make a joint. It is created but it is not working. Please help... BBRevoluteJointDef jointDefination = new BBRevoluteJointDef(); jointDefination.initialize(mBody, ((Pole)pole).g

  • How to keep sync a coop iphone game in cocos2d (+box2d) with gamekit? 2011-01-28

    so i have made a box2d game with cocos2d. The user can move the player and in the world there are dynamic objects. Now i thought of implementing a coop mode. I know there's gamekit. My thoughts: make one of the two devices (or more..) to the host. if

  • Game Objects setup in cocos2d + box2d 2010-08-11

    I am having a design issue, this may be due to the fact that i don't fully understand cocos2d and box2d yet. I want to create game objects that have a CCSprite(image data) and a b2Body(physics), Would i be right to make an encapsulating object that c

  • cocos2d + box2d: Rotation towards point 2010-10-08

    I'm attempting to rotate a box2d body that's tied to a cocos2d sprite via box2d's GetUserData() in my iPhone application. Specifically, I'm attempting to grab the latest touch location and rotate my box2d body in that direction. I'm fairly inexperien

  • [ios.cocos2d+box2d]how to disable auto-rotation? 2010-10-28

    I have created a project with cocos2d 0.99.5 + box2d. When I rotate my iphone, Screen automatically rotated too. So the boxes Flew up into the ceiling. How to disable auto-rotation? plz --------------Solutions------------- In coco2d 0.99.5, the templ

  • Getting contact points on bodies in Cocos2d & Box2d 2011-02-17

    I'm very new to Cocos2d and Box2d, I have been following tutorials and generally hacking. However, I have one problem I cannot solve. I create 2 bodies and fixtures (in the Box2d world) and create a "Contact Listener" object. This object stores a lis

  • How to split up levels? (cocos2d,box2d,iphone) to save CPU and memory? 2011-03-04

    so I'm going to create large levels. But there's a problem: There's much unseen space (it's a jump'n run like mario bros.) and this will use memory + cpu. so how could I split up my levels? I'm using Box2D+ cocos2d for iphone. Any ideas? Mayby just s

  • How to grab a b2Body and move it around the screen? (cocos2d,box2d,iphone) 2011-03-12

    I want to move any b2body that is touched on the screen around the screen. I've heard something about mouse joints.. I found that: http://iphonedev.net/2009/08/05/how-to-grab-a-sprite-with-cocos2d-and-box2d/ but I just gives me a lot of errors if i j

  • cocos2d/box2d trouble 2011-03-20

    I have just started working with cocos2d and box2d for iOS SDK, and have a few problems. I got the templates working, and got the test app (the one where you click the screen and a box with a random letter appears) to compile. My first problem is tha

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.113 (s). 11 q(s)