chipmunk stack fall effect - iphone

I am using chipmunk cocos 2d iphone ,in which i have to show stack fall effect when the objects are placed on the edge of other
object.My idea is to develop the effect like "Tower Box " game. I would like to know which properties of shape or body will create effect like "Tower Box " game .please let me know how can I fall that stack.

Cocos2d provides you with a few preset project options.
One of these is Cocos2d with Box2d, another is Cocos2d with Chipmunk. It is completely up to you which physics engine you use, I have experience with both and personally, would recommend Box2d.
If you create one of these projects, it generates some example code for you, and in the case of Box2d (i haven't used an auto generated chipmunk project), you get a nice little app that spawns loads of boxes and shows them falling with gravity. You should take a look at the code behind creating the physics bodies on the boxes and adapt it to suit your application (spawn a box at a touch location, perhaps?). You could then add some logic that checks, on collision, the alignment of the falling box with the top of the stack, and either let it continue falling, or use a fixture to attach it to the box below.
For more information about using physics in a cocos2d app, as well as general cocos2d usage, check out this blog, it's what taught me in the beginning: http://www.raywenderlich.com/ [edit: just noticed there are no chipmunk tutorials on there, but the theory should be applicable to both. I found Box2d easier to use than Chipmunk]
What physics effects have you got on the stack so far? What problem have you encountered that made you question the physics properties of the objects?

For these effects you need a physics library. For 2d games box2d is quite good.

Related

Bouncing Particles in a CCParticleSystemQuad

I'm using cocos2d to make a game on iOS. I have a particle emitter that I want the particles to bounce when they hit the bottom of the screen. Thing is I cannot seem to find a way to do this and with my limited understand of open GL the answer my be obviously in front of me but I don't see it. Is there an example of this or a way to use the CCBounce or box2d or something?
Here is a bouncing ball tutorial which uses cocos2d + Box2D:
http://www.raywenderlich.com/457/intro-to-box2d-with-cocos2d-tutorial-bouncing-balls
There is also EaseBounce actions (CCEaseBounceIn, CCEaseBounceOut, CCEaseBounceInOut) in cocos2d for you to run on sprites. See "EaseBounce actions" section in "cocos2d Programming Guide: Actions - Ease".

Iphone game cocos2d and box2d

I have image named "platform.png" that represents one brick for platform of a IPhone game. I have a cartoon character that will jump on this platform.
A series of platform.png will form one complete platform. These series will be generated by swiping finger across Iphone screen. When character will jump on this platform it should go down like elastic and bounce back up. Can anyone tell me how to do this ?
Thanks in advance.
What yo want is Collision Detection. I don't think using Cocos2d will be a great idea to use in this case because you want to show elastic and bounce effects which should seem real. For this, what I suggest, is using Box2d which clearly help in showing the effects in a natural way. Here Collision Detection can be handled in a separate class known as ContactListener. You can study Box2d and ContactListener here. In ContactListener you can generate these effects and this class is very easy to handle. Two or three months back I used the same to create my game Pogo Jump and believe me I was very easy to work on Box2d.
Good luck..!!
heye ,
you have two options for this , either use box-2d/chipmunk or dont.
If you have prior experience with Physics then i would say box-2d/chipmunk would look more realistic.

Would a game with a man walking on a planet be a tile based game?

Say there was a game, where you stay on a single screen (unless you pass the level), and you are a man walking around in space.
It seems like a tile based game to me, the only catch is that when you move, it has some physics at play, meaning the more you press up, the faster you move and the longer it takes to slow down.
And you also keep moving even if you stop pressing the arrow keys as you have gained momentum.
thoughts?
how would I handle the movement of the man based on momentum etc?
If you decide to use Cocos2d, start with this
Learn iPhone and iPad cocos2d Game Development
It has an example in the chapter "Your First Game" which covers Velocity calculations and controlling a players movement using these calculations.
Also as bbum mentioned
Ray Wenderlich has some great tutorials and is really educating developers on some interesting topics.
He also has co-authored a book which is available for pre-order.
Learning Cocos2D: A Hands-On Guide to Building iOS Games with Cocos2D, Box2D, and Chipmunk
Sure; it could easily be a tile based game and there are multiple examples of exactly that. Heck; Super Mario is a tile based game -- the level and backgrounds are all tile based layouts -- with the characters -- also tiles -- moving based on a very simple physics model.
Cocos2d is a tile based game engine that also has support for several physics engines.
Ray Wenderlich has written an excellent series of tutorials on uses of cocos2d. Here is one that includes physics to model a bouncing ball.
Either you have a game like lunar lander, where the position of the man is based on physics, or you have a tile based game. You cannot have both at the same time.

iPhone - What is the best way to create the physics for a game?

1- let's say there is a box on the screen and as soon as it gets hit by another box it suppose to move. How can i detect (getting hit) on my box object? Is it a good idea to use an nstimer which runs every 0.1 seconds and looking for the location of other objects around itself?
2- What is the best way to display simple 2d animations?
Install the Cocos2d templates and then instead of using the standard Cocos2d template use either the Chipmunk or Box2d template. Box2d has the benefit of C++ where Chipmunk is C based. Both still use Objective-C though for a lot of stuff. Heres where Cocos2d is. Note: All three templates have animation abilities.

Iphone GUI physics code

When you drag an iphone GUI element like a list, it scrolls in a physics correct way, and also has a nice bounce effect at the end.
I would like to write a GUI element in my game, without using UIKit. I wonder where is the code implementing this, and if I can use it instead of trying to write something similar.
Any ideas?
I think that a physics engine would be overkill for just animating a gui element (unless you already have a physics engine in your game).
You could try using animations but I've no experience of doing this without UIKit but I suppose you would start here?
If you didn't want to use Core Animation, I would take a look at Robert Penner's easing equations - they're in actionscript but are pretty simple to port to C and would be a good start to get your own animation code started.
Hope this helps,
Sam
You can perhaps use animations to achieve this, you can define animation paths for bouncing or doing whatever it is you need and activate them when needed. I think the example project MoveMe can help you out
I can recommend the O'Reilly book "Physics for Game Developers" by David Bourg, which has great coverage of algorithms and code for all sorts of simulations. You probably want to start with motion affected by drag for the flick and gradual slowing, then look at a spring model to simulate the damping at the end.
box2d is an open source project that provides a great 2d physics engine.
this library is used by Intel clutter, which is a nice physics oriented UI library that is capable of running on mobile devices. that means that box2d is already optimized for mobile platforms like the iphone.