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
gdevelop5:tutorials:space-shooter:8-powerups [2020/11/23 10:56]
dkarakay
gdevelop5:tutorials:space-shooter:8-powerups [2021/02/14 23:09] (current)
mannhb [Testing out]
Line 12: Line 12:
 6. [[gdevelop5:tutorials:space-shooter:6-enemy-mechanics|Space Shooter, Part 6]] 6. [[gdevelop5:tutorials:space-shooter:6-enemy-mechanics|Space Shooter, Part 6]]
 7. [[gdevelop5:tutorials:space-shooter:7-meteors|Space Shooter, Part 7]] 7. [[gdevelop5:tutorials:space-shooter:7-meteors|Space Shooter, Part 7]]
-7. [[gdevelop5:tutorials:space-shooter:8-powerups|Space Shooter, Part 8]]+8. [[gdevelop5:tutorials:space-shooter:8-powerups|Space Shooter, Part 8]] 
 +9. [[gdevelop5:tutorials:space-shooter:9-ui|Space Shooter, Part 9]] 
 +10. [[gdevelop5:tutorials:space-shooter:10-sound-effects-music|Space Shooter, Part 10]] 
 +11. [[gdevelop5:tutorials:space-shooter:11-visual-effects|Space Shooter, Part 11]] 
 +12. [[gdevelop5:tutorials:space-shooter:12-levels|Space Shooter, Part 12]] 
 +13. [[gdevelop5:tutorials:space-shooter:13-main-menu|Space Shooter, Part 13]]
  
-<note tip> This chapter will learn how to add two different powerups to the game. </note>+<note tip> In this chapter, we will learn how to add two different powerups to the game. </note>
  
 ## Adding powerups ## Adding powerups
  
-We will add two objects called **"PowerupHealth"**and **"PowerupShield"**Select the **"powerup\_health.png"** image from the assets folder for the health object. Repeat the same process for shield object by choosing the **"powerup\_shield.png"** image. In the end, you should see:+We will add two objects called **"PowerupHealth"** and **"PowerupShield."** Select the **"powerup\_health.png"** image from the assets folder for the health object. Repeat the same process for shield object by choosing the **"powerup\_shield.png"** image. In the end, you should see:
  
 {{ :gdevelop5:tutorials:space-shooter:space-shooter-adding-powerup-objects.png?nolink |}} {{ :gdevelop5:tutorials:space-shooter:space-shooter-adding-powerup-objects.png?nolink |}}
  
-Then create an object group called **"Powerups"**.+Then create an object group called **"Powerups."**
  
-{{ :gdevelop5:tutorials:space-shooter:space-shooter-meteor-objects.png?nolink |}}+{{ :gdevelop5:tutorials:space-shooter:space-shooter-adding-powerup-group.png?nolink |}}
  
 ## Animating the player ## Animating the player
  
-We are using animations to change the player's sprite when the player collides with **PowerupShield**. Open the player's properties panel and enter **"PlayerIdle"** in Animation#0. Then add a new animation called **"PlayerShield"**and select **"player\_shield.png"** from the assets folder.+We are using animations to change the player's sprite when the player collides with **PowerupShield**. Open the player's properties panel and enter **"PlayerIdle"** in Animation#0. Then add a new animation called **"PlayerShield,"** and select **"player\_shield.png"** from the assets folder.
  
 {{ :gdevelop5:tutorials:space-shooter:space-shooter-player-animation-min.gif?nolink |}} {{ :gdevelop5:tutorials:space-shooter:space-shooter-player-animation-min.gif?nolink |}}
Line 34: Line 39:
 ## Giving extra health to the player ## Giving extra health to the player
  
-We are ready to open **"Events"** page. We will add a new condition to check the collision between the **Player** and the **PowerupHealth** objects. If the collision happens, we want to **increase the player's health by 30** and **delete** the powerup object since we do not need it anymore.+We are ready to open the **"Events"** page. We will add a new condition to check the collision between the **Player** and the **PowerupHealth** objects. If the collision happens, we want to **increase the player's health by 30** and **delete** the powerup object since we do not need it anymore.
  
 <note tip> You can add a comment to classify your events.</note> <note tip> You can add a comment to classify your events.</note>
Line 46: Line 51:
 Go to the **"IsDamaged"** condition and add a new condition to check if the **PowerupShield** variable is **equal to 0**.  Go to the **"IsDamaged"** condition and add a new condition to check if the **PowerupShield** variable is **equal to 0**. 
  
-<note tip> We are going to use this condition to prevent getting damage while using the powerup</note>+<note tip> We are going to use this condition to prevent getting damaged while using the powerup.</note>
  
 {{ :gdevelop5:tutorials:space-shooter:space-shooter-scale-powerups-min.gif?nolink |}} {{ :gdevelop5:tutorials:space-shooter:space-shooter-scale-powerups-min.gif?nolink |}}
Line 54: Line 59:
 {{ :gdevelop5:tutorials:space-shooter:space-shooter-check-the-poweup-shield-is-zero.png?nolink |}} {{ :gdevelop5:tutorials:space-shooter:space-shooter-check-the-poweup-shield-is-zero.png?nolink |}}
  
-Create a new condition for detecting the collision between the Player and the PowerupShield objects. Then, add a new action to change the animation of the player. Select Player, and choose **"Change the animation (by name)"** and enter "PlayerShield" in the animation name.+Create a new condition for detecting the collision between the **Player** and the **PowerupShield** objects. Then, add an action to change the animation of the player. Select Player, and choose **"Change the animation (by name)"** and enter **"PlayerShield"** in the name field.
  
 {{ :gdevelop5:tutorials:space-shooter:space-shooter-change-animation-to-shield.png?nolink |}} {{ :gdevelop5:tutorials:space-shooter:space-shooter-change-animation-to-shield.png?nolink |}}
  
-Then, add some actions to **set "PowerupShield" to 1**, **delete the "PowerupShield"** object. In the end, you should see:+Then, add some further actions to **set "PowerupShield" to 1**, **delete the "PowerupShield"** object, and reset a timer called "PowerupShield.In the end, you should see these events: 
 + 
 +<note tip> We will use this timer to determine the usage of powerup in the next steps.</note>
  
 {{ :gdevelop5:tutorials:space-shooter:space-shooter-player-collision-with-powerup-shield.png?nolink |}} {{ :gdevelop5:tutorials:space-shooter:space-shooter-player-collision-with-powerup-shield.png?nolink |}}
  
 +Add a new condition to check whether the **"PowerupShield"** variable is **equal to 1** or not. Then, add a sub-event to check the **timer called "PowerupShield" is greater than 5 seconds**.
 +
 +{{ :gdevelop5:tutorials:space-shooter:space-shooter-add-powerup-timer.png?nolink |}}
 +
 +Finally, we are going to set "**PowerupShield"** and **"IsDamaged"** variables to **0** and **change the animation** of the player to **"PlayerIdle."** We also need to reset the timer called **"PowerupShield."** In the end, your events should look like this:
  
 +{{ :gdevelop5:tutorials:space-shooter:space-shooter-chapter-8-events.png?nolink |}}
  
 ## Testing out ## Testing out
  
-Before testing out the meteors, we should **put some meteor objects on the scene****Drag and drop** some meteor items on the scene.+Before testing powerups, we should change the scale of powerup objects just like in the previous cases. Select **Powerups object group** and set scale factor to **1.5**:
  
-{{ :gdevelop5:tutorials:space-shooter:space-shooter-drag-adn-drop-meteors-min.gif?nolink |}}+{{ :gdevelop5:tutorials:space-shooter:space-shooter-scale-powerups.png?nolink |}}
  
-Run the game. Now you can see the meteors on the scene. If you hit some meteors, you will get damage+Then, open the scene view and drag and drop the powerup objects to the scene. We are ready to run the game. Now you can see the powerups on the scene. If you collect **health's powerup**, **the player's health will be increased by 30**. If you collect the **shield's powerup**, the **player's sprite will be changed**and you will not get damaged for 5 seconds.
  
-{{ :gdevelop5:tutorials:space-shooter:space-shooter-chapter-7-demo-min.gif?nolink |}}+{{ :gdevelop5:tutorials:space-shooter:space-shooter-chapter-8-demo-min.gif?nolink |}}
  
 +##Next step
  
 +[[gdevelop5:tutorials:space-shooter:9-ui|Space Shooter, Part 9]]