I’m playing around with android and would like to try out to simulate a grenade movement with a sine wave. Would any one please help me with the syntax?
This is what I tried with the small math knowledge I have:
mPositionX += mSpeed;
mPositionY = (float) (0.5f * Math.sin(mTargetX * mPositionX));
setPosition(mPositionX, mPositionY);
But it doesnt really do what I excpected..
My mPositionX/Ys initial value is the spawnpoint of the grenade and mTargetX/Y is where I would like the sine wave to have done a half wave (like a semi circle) in other words; where the grenade should land.
My position values is in percentages so 0.5 is half of the canvas etc. if worth to mention.
The concept you’ve used for a sine wave seems strange.
In a sine wave the equation is
This should work for a sine wave
Now in the repeatedly called
onDraw