So in my game a have this paddle and a ball, and i want to calculate which side of the paddle that the ball hits, i found this answer in C# which shows drawing two lines like this:
So what i want to do is draw two hypothetical lines(meaning invisible to the user) so i can calculate if the ball is greater then both the lines or if its in contact with one of the sides of the paddle.
How do i draw these lines in sprite kit and swift?
UPDATE
I found the original answer, its HERE
You can check the position of the ball in relation to the paddle.
If(ballNode.position.x > paddleNode.position.x) {
// ball is on the right of the paddle
} else {
// ball is on the left of the paddle
}
If(ballNode.position.y > paddleNode.position.y) {
// ball is above the paddle
} else {
// ball is below the paddle
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.