Hello there,
I am a bit confused with the update() of JumpBy
.
I am trying to implement the same but without the action class, i.e i want to implement it in a update function.
Could anyone please make me understand this block of code
void JumpBy::update(float t)
{
// parabolic jump (since v0.8.2)
if (_target)
{
float frac = fmodf( t * _jumps, 1.0f );
float y = _height * 4 * frac * (1 - frac);
y += _delta.y * t;
float x = _delta.x * t;
#if CC_ENABLE_STACKABLE_ACTIONS
Vec2 currentPos = _target->getPosition();
Vec2 diff = currentPos - _previousPos;
_startPosition = diff + _startPosition;
Vec2 newPos = _startPosition + Vec2(x,y);
_target->setPosition(newPos);
_previousPos = newPos;
#else
_target->setPosition(_startPosition + Vec2(x,y));
#endif // !CC_ENABLE_STACKABLE_ACTIONS
}
}
Like say - I have a start position and an end position.
how do i get the x and y value for each frame and how is time of action playing a role in it. !!
I want to override the same logic with some offset of x value in the game (wind effect offset)
Thanks in advance
could you help @slackmoehrle !! please…