Finding 'suitable' horizontal and vertical speed from an angle - android
im using a particle system and have it so when it creates the particle it passes a starting x and y value and from that i get an angle to where i want to shoot the particle but i need it so i have a vertical speed and a horizontal speed so what can i can?
hack and slash of my particle:
Particle(int x, int y,int x2,int y2) {
this.x = x;
this.y = y;
this.state = BulletParticle.STATE_ALIVE;
this.widht = MAX_DIMENSION;//rndInt(1, MAX_DIMENSION);
this.height = this.widht;
// this.height = rnd(1, MAX_DIMENSION);
this.lifetime = DEFAULT_LIFETIME;
this.age = 0;
this.xv = x2;//(rndDbl(0, MAX_SPEED * 2) - MAX_SPEED);
this.yv = y2;//(rndDbl(0, MAX_SPEED * 2) - MAX_SPEED);
// s开发者_C百科moothing out the diagonal speed
if (xv * xv + yv * yv > MAX_SPEED * MAX_SPEED) {
xv *= 0.7;
yv *= 0.7;
}
Work out how long you want the particle to cross the whole of the width, or the height, then use s = 0.5 * a * t^2 + v0 * t to work out v0, the initial speed (take a look at the equations of motion).
If it's not accelerating or decelerating, you can just use s = v0 * t ...
精彩评论