This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| en:guides:beginners:text_and_game_over [2018/06/29 12:38 (7 years ago)] – In line with init projects sausage | en:guides:beginners:text_and_game_over [2025/09/30 17:26 (4 weeks ago)] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 16: | Line 16: | ||
| Graphic | Graphic | ||
| Position = (-380, -280, 0) | Position = (-380, -280, 0) | ||
| + | Scale = 2 | ||
| </ | </ | ||
| Line 22: | Line 23: | ||
| Now, in code, add a score variable and a scoreObject at the top of the file: | Now, in code, add a score variable and a scoreObject at the top of the file: | ||
| - | < | + | < |
| orxOBJECT *hero; | orxOBJECT *hero; | ||
| orxOBJECT *herosGun; | orxOBJECT *herosGun; | ||
| Line 31: | Line 32: | ||
| Next, create a score object and assign it to the scoreObject variable in the Init() function: | Next, create a score object and assign it to the scoreObject variable in the Init() function: | ||
| - | < | + | < |
| + | hero = orxObject_CreateFromConfig(" | ||
| + | herosGun = (orxOBJECT*)orxObject_GetChild(hero); | ||
| scoreObject = orxObject_CreateFromConfig(" | scoreObject = orxObject_CreateFromConfig(" | ||
| </ | </ | ||
| Line 42: | Line 45: | ||
| orxCHAR formattedScore[6]; | orxCHAR formattedScore[6]; | ||
| - | | + | |
| orxObject_SetTextString(scoreObject, | orxObject_SetTextString(scoreObject, | ||
| Line 50: | Line 53: | ||
| Add 250 points whenever a monster is hit with a bullet. Add UpdateScore() function calls to: | Add 250 points whenever a monster is hit with a bullet. Add UpdateScore() function calls to: | ||
| - | < | + | < |
| if (orxString_Compare(senderObjectName, | if (orxString_Compare(senderObjectName, | ||
| CreateExplosionAtObject(pstRecipientObject, | CreateExplosionAtObject(pstRecipientObject, | ||
| Line 68: | Line 71: | ||
| And of course, 1000 points bonus if the star is reached. Add the following code: | And of course, 1000 points bonus if the star is reached. Add the following code: | ||
| - | < | + | < |
| if (orxString_Compare(senderObjectName, | if (orxString_Compare(senderObjectName, | ||
| orxObject_SetLifeTime(pstSenderObject, | orxObject_SetLifeTime(pstSenderObject, | ||
| Line 86: | Line 89: | ||
| A final thing for the game will be to add a game over panel when the hero dies. For this, we'll have an object that gets created using a timeline track after a two second delay. First, a game over asset: | A final thing for the game will be to add a game over panel when the hero dies. For this, we'll have an object that gets created using a timeline track after a two second delay. First, a game over asset: | ||
| - | {{ tutorials:community: | + | {{ tutorials:tracks: |
| - | Save this into the '' | + | Save this into the '' |
| Create a simple gameover graphic and object: | Create a simple gameover graphic and object: | ||
| Line 111: | Line 114: | ||
| Then finally, change the physics handler code, so that when the hero is destroyed, create the timeline track. After a two second delay, the '' | Then finally, change the physics handler code, so that when the hero is destroyed, create the timeline track. After a two second delay, the '' | ||
| - | < | + | < |
| if (orxString_Compare(recipientObjectName, | if (orxString_Compare(recipientObjectName, | ||
| orxString_Compare(senderObjectName, | orxString_Compare(senderObjectName, | ||
| Line 131: | Line 134: | ||
| </ | </ | ||
| - | Because we never had a reference to the scene before in order to add the PopUpGameOverTrack, | + | Because we never had a reference to the '' |
| - | < | + | < |
| orxOBJECT *hero; | orxOBJECT *hero; | ||
| orxOBJECT *herosGun; | orxOBJECT *herosGun; | ||
| Line 141: | Line 144: | ||
| </ | </ | ||
| - | And then set the '' | + | And then set the '' |
| - | < | + | < |
| + | scoreObject = orxObject_CreateFromConfig(" | ||
| + | orxObject_Enable(herosGun, | ||
| scene = orxObject_CreateFromConfig(" | scene = orxObject_CreateFromConfig(" | ||
| </ | </ | ||
| Line 157: | Line 162: | ||
| If you need quick examples, you can visit the [[en: | If you need quick examples, you can visit the [[en: | ||
| - | If you get stuck, please post it to the [[http:// | + | If you get stuck, please post over on our [[https:// |
| {{section> | {{section> | ||