So I’m already familiar with the isTouching method which is called on a sprite with another sprite passed in as an argument, and returns a Boolean showing whether or not the two sprites are currently touching each other.
I am trying to make a more traditional paddle-ball type game out of Lesson 25, challenge 10b-c, where bricks become weaker and eventually disappear when the ball runs into them.
Right now, I am using if-statements to check each brick being touched before the ball bounces off of it. I noticed the lag when the ball does touch the brick and I think this is an inefficient way to constantly be polling for whether or not the brick touches the ball.
A better way would be to figure out that the ball is touching something, and receive a return value of the sprite which the ball is touching. I suppose I could track changes in the ball’s velocity to determine when it bounces off something, and figure out which brick it is near using its location, but I was wondering if there’s already a function written which could help figure out what the sprite is running into.
Or is there a way to leverage the bounceOff function to accomplish this task?
Any input would be greatly appreciated, thanks!