![]() You can also change the color of the ColorRect node to something like White, to make it easier to tell what is the ball. Then select the ColorRect child node in “Ball” and make it a different size, like a small square. Set the “Ball” node in the middle of the screen. Finally, copy the “Paddle_AI” and rename it to “Ball”.To help with visually knowing which is which, you can select the ColorRect child node in “Paddle_AI” and make it a different color. Copy the “Paddle_Player” node, rename it to “Paddle_AI”, and position it to where you want the AI’s paddle to be on the right side.Position the “Paddle_Player” node on the left side of the screen to wherever you want the player’s paddle to be.Finally, position the CollisionShape2D over the ColorRect node. Then select the CollisionShape2D node and make a RectangleShape2D shape, and set its size to half of the ColorRect node’s size. ![]() I choose 32 pixels wide and 128 pixels high as the “size” (under the “Rect” category) and set my paddle to use a green color. Set the ColorRect node to whatever size and color you want your paddle. Make a ColorRect node and a CollisionShape2D node, and set these as children of the KinematicBody2D node. Next, create a KinematicBody2D node and name it “Paddle_Player”.This will place the text in the center of the screen. Then, still with the label selected, go to the inspector tab on the right and set the “Align” and “Valign” properties to “Center”. With the Label node selected, press the “Layout” tab and select “Full Rect”. Create a Label node and call it “Score_Label”.These StaticBody2D nodes will keep the ball in our game of Pong within the game area. Then copy the StaticBody2D node and place it so it covers the bottom of the “BG” ColorRect node. Once this is done position the StaticBody2D node so it covers the top of the “BG” ColorRect node.When finished, you should have something like this: Then select the CollisionShape2D node, make a RectangleShape2D, set its size to half of the size of the ColorRect node, and position it in place. Using the transform tools/handles in the scene view, select the ColorRect node and make the size of the ColorRect node fit the size of the game window.Set the color of the ColorRect node to something that will show on the screen, but is not too different than the background, so players can see that it is a boundary. Make the ColorRect node and the CollisionShape2D node children of the StaticBody2D node. Make a StaticBody2D node, a ColorRect node, and a CollisionShape2D node.Set the color of the ColorRect node to whatever color you want your background to be. Select the “Layout” tab and select “Full Rect” again. Create a new ColorRect node and name it “BG”.This will scale the Control node so it always take the full size of the game window. This will bring a dropdown of various anchor and layout modes. Select the root control node and in the top bar in the middle window, the scene view, select the “Layout” tab.Rename the control node to whatever you want (I named mine “OneFilePong”), and then perform the following steps: From there, you will be given a Control node as the root node of the scene.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |