The method creates a sprite with the specified coordinates and adds it to the game. The anchor field is responsible for the origin of the sprite coordinates, set it to the center of the paddle image. body contains elements for working with physics. Here we restrict the movement of the paddle to the outside of the playing space, set the “bounce” force, and indicate that when colliding with objects, the paddle will not bounce to the side.
Let’s add two calls to this function to create (), right after the background is created. The rackets will be added to the game after the background image, so we will see them on the screen:
The picture turned out to be pretty, but I think we should revive it a little.