Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
gdevelop5:tutorials:tank-shooter [2019/05/29 18:34]
akbarhabeebb [Shoot bullets with the turret] Typo
gdevelop5:tutorials:tank-shooter [2019/06/13 20:36]
piyushpalawat99 [Create the player turret]
Line 46: Line 46:
 ==== Create the player turret ==== ==== Create the player turret ====
  
-The player will be controlling a turret to shoot  the enemies.+The player will be controlling a turret to shoot the enemies.
 In the Scene "​Objects"​ editor choose "Add a new object"​. ​ In the Scene "​Objects"​ editor choose "Add a new object"​. ​
 {{ :​gdevelop5:​tutorials:​add_new_object.png?​nolink |}} {{ :​gdevelop5:​tutorials:​add_new_object.png?​nolink |}}
Line 61: Line 61:
 {{ :​gdevelop5:​objects:​animation-properties.png?​nolink |}} {{ :​gdevelop5:​objects:​animation-properties.png?​nolink |}}
  
-You need to add the turret image as an animation. ​ Click the big plus symbol {{:​gdevelop5:​tutorials:​plusaddobject.png?​24|}}. Browse to the project folder. Find the image aaguntopdown.png.+You need to add the turret image as an animation. ​ Click the big plus symbol {{:​gdevelop5:​tutorials:​plusaddobject.png?​|}}. Browse to the project folder. Find the image aaguntopdown.png.
 The image will be displayed in the window. The image will be displayed in the window.
 {{ :​gdevelop5:​tutorials:​turret-animation-window.png?​nolink |}} {{ :​gdevelop5:​tutorials:​turret-animation-window.png?​nolink |}}
Line 314: Line 314:
 {{ :​gdevelop5:​tutorials:​turret-screenshot-enemies-are-exploding.png?​nolink |}} {{ :​gdevelop5:​tutorials:​turret-screenshot-enemies-are-exploding.png?​nolink |}}
 ==== Adding more explosions and a Game Over ==== ==== Adding more explosions and a Game Over ====
-Until now, the player could not die. When an enemy tank is hitting the player'​s turret, we want the turret to be destroyed .+Until now, the player could not die. When an enemy tank is hitting the player'​s turret, we want the turret to be destroyed.
 Add a new event. Follow the same procedure that you followed to create an event to destroy the enemies. ​ Add a new event. Follow the same procedure that you followed to create an event to destroy the enemies. ​
   * Add a condition to test for a collision between a tank and the turret. ​   * Add a condition to test for a collision between a tank and the turret. ​
Line 328: Line 328:
 Now, change the text to "Game Over", ​ the text color to red, and the text size to 40.  Now, change the text to "Game Over", ​ the text color to red, and the text size to 40. 
 {{ :​gdevelop5:​tutorials:​edit-text-object.png?​nolink |}} {{ :​gdevelop5:​tutorials:​edit-text-object.png?​nolink |}}
-We can also set a custom font by simply entering the path of the font. In this case our font is located in the project folder. We only need to enter the name of the font file:+We can also set a custom font by simply entering the path of the font. In this caseour font is located in the project folder. We only need to enter the name of the font file:
 {{ :​gdevelop5:​tutorials:​custom-text-font.png?​nolink |}} {{ :​gdevelop5:​tutorials:​custom-text-font.png?​nolink |}}
  
 Finally, add the "Game Over" text object to the scene. Finally, add the "Game Over" text object to the scene.
  
-The next step is to hide the text object. Then,if there is no turret in the scene, (meaning the turret is destroyed) we will display it.+The next step is to hide the text object. Then, if there is no turret in the scene, (meaning the turret is destroyed) we will display it.
 Add a new blank event and add the condition "​Scene",​ "At the beginning of the scene"​. Add a new blank event and add the condition "​Scene",​ "At the beginning of the scene"​.
 {{ :​gdevelop5:​tutorials:​at-the-beginning-of-the-scene-condition.png?​nolink |}} {{ :​gdevelop5:​tutorials:​at-the-beginning-of-the-scene-condition.png?​nolink |}}
Line 383: Line 383:
 If you run the preview now, probably you won't notice any difference as the game is very simple and you most likely using a device with at least 2GB of RAM and a dual-core CPU. So there is plenty of resources for our simple game but in case we would create hundreds and thousands of bullets that you are free to try you may notice a little slow down after a while without destroying them. If you run the preview now, probably you won't notice any difference as the game is very simple and you most likely using a device with at least 2GB of RAM and a dual-core CPU. So there is plenty of resources for our simple game but in case we would create hundreds and thousands of bullets that you are free to try you may notice a little slow down after a while without destroying them.
 ==== Add a background ==== ==== Add a background ====
- One last thing is to add a background. ​ This will give the game a more finished look .+ One last thing is to add a background. ​ This will give the game a more finished look.
  
-Add a new Sprite object. Name it background. Add the "​background.jpg"​ image to the object. Next, you can add the object to the scene as usual. Make sure it fills the entire scene. To make it easier, you can enable the grid using the button on the top and it should help with positioning the object.+Add a new Sprite object. Name it "background". Add the "​background.jpg"​ image to the object. Next, you can add the object to the scene as usual. Make sure it fills the entire scene. To make it easier, you can enable the grid using the button on the top and it should help with positioning the object.
 {{ :​gdevelop5:​toggle-grid-button.png?​nolink |}} {{ :​gdevelop5:​toggle-grid-button.png?​nolink |}}
 Notice that the background object covers all of the other objects. To solve this problem, we need to change the Z-order of the object. While the background object is selected, on the left of the Scene Editor screen, you will see a "​Properties"​ list. If you don't see the "​Properties"​ list, you can open it using the "​Properties"​ button on the toolbar that is located at the top of the GD interface. Notice that the background object covers all of the other objects. To solve this problem, we need to change the Z-order of the object. While the background object is selected, on the left of the Scene Editor screen, you will see a "​Properties"​ list. If you don't see the "​Properties"​ list, you can open it using the "​Properties"​ button on the toolbar that is located at the top of the GD interface.
Line 391: Line 391:
 We can change all kinds of properties using the Property Editor. ​ The position, angle, and size of the object can be changed. In this case, we want to change the Z-order. ​ We can change all kinds of properties using the Property Editor. ​ The position, angle, and size of the object can be changed. In this case, we want to change the Z-order. ​
 {{ :​gdevelop5:​objects:​object-zorder-properties.png?​nolink |}} {{ :​gdevelop5:​objects:​object-zorder-properties.png?​nolink |}}
-Change the value of the Z-order to a low number. For the background we will use a negative number ​ - 1.+Change the value of the Z-order to a low number. For the backgroundwe will use a negative number ​ - 1.
 The reason for the negative value is that when we are creating the bullets, enemies, and explosions we are creating them at Z-order 0 by default. We need to position the background below 0 otherwise we won't see anything but the turret in our game. Another way to fix it is to tell GDevelop to position the tanks and explosions and bullets on a higher Z-order. We can position the background at 0 but it is something that you the developer need to decide for your self. Every problem can have a number of different solutions. The reason for the negative value is that when we are creating the bullets, enemies, and explosions we are creating them at Z-order 0 by default. We need to position the background below 0 otherwise we won't see anything but the turret in our game. Another way to fix it is to tell GDevelop to position the tanks and explosions and bullets on a higher Z-order. We can position the background at 0 but it is something that you the developer need to decide for your self. Every problem can have a number of different solutions.