From 553b065e8d2321a9c0e1ea82212198a34f5e2f3b Mon Sep 17 00:00:00 2001 From: Mashy Date: Thu, 11 Jul 2019 16:13:22 +1000 Subject: [PATCH] rotations --- client/src/components/anims/slay.jsx | 32 +++++++++++--------------- client/src/components/anims/strike.jsx | 30 +++++++++++------------- 2 files changed, 28 insertions(+), 34 deletions(-) diff --git a/client/src/components/anims/slay.jsx b/client/src/components/anims/slay.jsx index 54a2eae5..c11f1025 100644 --- a/client/src/components/anims/slay.jsx +++ b/client/src/components/anims/slay.jsx @@ -67,27 +67,23 @@ class AttackCharge extends Component { } componentDidMount() { + 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, - }); + 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; } -/* if (!this.props.team) { - anime.set('.skill-anim', { - rotate: Math.random() * 180 + 90, - }); - } else { - anime.set('.skill-anim', { - rotate: Math.random() * 180 + 270, - }); - } -*/ anime.set('.skill-anim', { + anime.set('.skill-anim', { + rotate, + }); + + anime.set('.skill-anim', { translateY: -400, translateX: 0, opacity: 0, diff --git a/client/src/components/anims/strike.jsx b/client/src/components/anims/strike.jsx index 1d1d8a0c..86f61dd0 100644 --- a/client/src/components/anims/strike.jsx +++ b/client/src/components/anims/strike.jsx @@ -61,28 +61,26 @@ class Strike extends Component { } componentDidMount() { - console.log(this.props.direction); -/* 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; + let rotate = 0; // Self target value 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', { - translateY: -300 * this.props.direction.y, - translateX: -150 * this.props.direction.x, rotate, }); + anime.set('#strike', { + translateY: -400, + translateX: 0, + }); + this.animations.push(anime({ targets: '#strike', opacity: [