how can i have custom tween with following properties
1:easeIn fall
2:rotate depending on easein fall(different at differnt points)
3:fall under gravity
Any solution?
how can i have custom tween with following properties
1:easeIn fall
2:rotate depending on easein fall(different at differnt points)
3:fall under gravity
Any solution?
Could you explain your question in a little more detail, please? I'm not sure I understand exactly what you want to achieve.
Thanks!
i have many objects falling under gravity..The object changes direction due to fan and falls in easein method that sparrow tween supports..i want the object to rotate a little to cause that fan effect on the object.
hi, if i correctly understood your problem this should help, when you want the rotation to "happen"
SPTween *tween = [SPTween tweenWithTarget:_mySpriteOrImage time:HowLongFromCurrentToTarget transition:SP_TRANSITION_EASE_IN];
[tween animateProperty:@"rotation" targetValue:SP_D2R(angleinDegree)];
[self.stage.juggler addObject:tween];
_mySpriteOrImage is what you want to rotate,
HowLongFromCurrentTarget is how long you want the animation to last
angleInRadians is the final angle that you are looking for (remember that more than 1 turns means more than 360 degrees,
example
"the wind pushes my item for 2 spins clockwise, the whole animation completes in 3 seconds"
SPTween *tween = [SPTween tweenWithTarget:_mySpriteOrImage time:3.0 transition:SP_TRANSITION_EASE_IN];
[tween animateProperty:@"rotation" targetValue:SP_D2R(360*2)];
[self.stage.juggler addObject:tween];
The amount of rotation and time is not super easy to calculate, requires some physics knowledge/understanding, in my opinion you can find a value by tweaking it by trial and error 'till you get a result that satisfies you. If you are still not happy try to read a bit on angular momentum and or write in here i'm sure there is plenty people happy to help.
To add the gravity it's slightly different you can't tween that i'm afraid you can however very easely simulate it, in the OnEnterFrame function you can add something like
myObject.y = myObject.initialY - 0.5*(9.8*timeFromStart)*(9.8*timeFromStart);
this ignores the object weight, if important tell me i come up with a different formula (this is a simple free fall formula on earth gravity values gravity)
I hope to have understood your question correctly and have answered in an appropriate manner so that Daniel will appreciate.
Durrza, thanks for that detailed answer! =)
Nilaf_prince, the nice thing about your problem is that each of your desired effects act on a different property:
* falling: object.y
* rotation: objection.rotation
* movement by wind: object.x
So you can have the gravitation-tween move the object downward. When the wind starts, you can start a rotation-tween, and a x-movement tween -- just as Durrza described.
An alternative would be to use no tweens at all, but a simple physics system. You can find the code for that in this forum thread.
Really helpful but i want to correct durrza
myObject.y = myObject.y + 0.5*(9.8*timeFromStart)*(9.8*timeFromStart);
The y value should increase with acceleration .
Whatever it really helped me durrza.Thanks for that
yeah, was writing in a bit of a rush, but glad it helped anyhow
Side note, that formula implies that 1 pixel 1 meter (gravity acceleration is 9.8 m/s), i reckon in a game is not very realistic, might need adjusting.
i want to correct formula
initialize
obj.starttime=0.2; ( should been zero but to coz a force acting effect)
onEnterFrame
obj.starttime+=1/60.0;
obj.y+=obj.starttime*obj.starttime*4.9;
You must log in to post.