rotations

This commit is contained in:
Mashy 2019-07-11 16:13:22 +10:00
parent 9ffd0f868e
commit 553b065e8d
2 changed files with 28 additions and 34 deletions

View File

@ -67,27 +67,23 @@ class AttackCharge extends Component {
} }
componentDidMount() { componentDidMount() {
let rotate = 0; // Self target value
if (this.props.direction.y) { if (this.props.direction.y) {
anime.set('#strike', { if (!this.props.direction.x) rotate = this.props.direction.y > 0 ? 0 : 180;
rotate: -Math.atan(this.props.direction.y / this.props.direction.x) * 180 / Math.PI, else {
}); rotate = this.props.direction.y > 0
console.log(Math.atan(this.props.direction.y / this.props.direction.x) * 180 / Math.PI); ? -Math.atan(this.props.direction.y / this.props.direction.x) * 180 / Math.PI
} else { : -Math.atan(this.props.direction.y / this.props.direction.x) * 180 / Math.PI + 180;
anime.set('#strike', { }
rotate: 90, } else if (this.props.direction.x) {
}); rotate = this.props.direction.x > 0 ? 270 : 90;
} }
/* if (!this.props.team) { anime.set('.skill-anim', {
anime.set('.skill-anim', { rotate,
rotate: Math.random() * 180 + 90, });
});
} else { anime.set('.skill-anim', {
anime.set('.skill-anim', {
rotate: Math.random() * 180 + 270,
});
}
*/ anime.set('.skill-anim', {
translateY: -400, translateY: -400,
translateX: 0, translateX: 0,
opacity: 0, opacity: 0,

View File

@ -61,28 +61,26 @@ class Strike extends Component {
} }
componentDidMount() { componentDidMount() {
console.log(this.props.direction); let rotate = 0; // Self target value
/* if (this.props.direction.y) {
anime.set('#strike', {
rotate: -Math.atan(this.props.direction.y / this.props.direction.x) * 180 / Math.PI,
});
console.log(Math.atan(this.props.direction.y / this.props.direction.x) * 180 / Math.PI);
} else {
anime.set('#strike', {
rotate: 90,
});
}
*/
let rotate = 90;
if (this.props.direction.y) { if (this.props.direction.y) {
if (!this.props.direction.x) rotate = 0; if (!this.props.direction.x) rotate = this.props.direction.y > 0 ? 0 : 180;
else {
rotate = this.props.direction.y > 0
? -Math.atan(this.props.direction.y / this.props.direction.x) * 180 / Math.PI
: -Math.atan(this.props.direction.y / this.props.direction.x) * 180 / Math.PI + 180;
}
} else if (this.props.direction.x) {
rotate = this.props.direction.x > 0 ? 270 : 90;
} }
anime.set('#strike', { anime.set('#strike', {
translateY: -300 * this.props.direction.y,
translateX: -150 * this.props.direction.x,
rotate, rotate,
}); });
anime.set('#strike', {
translateY: -400,
translateX: 0,
});
this.animations.push(anime({ this.animations.push(anime({
targets: '#strike', targets: '#strike',
opacity: [ opacity: [