1

I want to show an effect of falling blocks which settle down at pre-determined position after some falling animation. Can this be done without using physics engine?

guru
  • 667
  • 5
  • 13

3 Answers3

2

I found a better and easier way to do this in cocos2d by using CCJumpTo action

CCActionInterval *jump1 = [CCJumpTo actionWithDuration:3 position:sp.position height:150 jumps:2];
sp.position = ccp(10,100);
[sp runAction:jump1];

Where sp is the CCSprite for the block.

guru
  • 667
  • 5
  • 13
0

All you need is to simulate gravity, the acceleration of the object. This could be achieved quite easily with a custom animation curve. Please have a look at this QA "how-to-create-custom-easing-function-with-core-animation", which shows a way to create the curve you need. Here is some more about "Animation Types Timing" by Apple.

The function you are looking for is called functionWithControlPoints, which has four input parameteres, so yes you can put in any random element you wish with a custom curve.

Community
  • 1
  • 1
Nick Weaver
  • 47,228
  • 12
  • 98
  • 108
0

"Easing" is your answer. You can choose the method that you need visually from the links below.

Tim Groleau's easing generator

jQuery Easing Demos

marzapower
  • 5,531
  • 7
  • 38
  • 76
bateristt
  • 176
  • 15