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/02/13 20:47 (7 years ago)] – ↷ Links adapted because of a move operation iarwain | en:guides:beginners:text_and_game_over [2024/11/19 04:21 (4 months ago)] (current) – Highlights sausage | ||
---|---|---|---|
Line 15: | Line 15: | ||
[ScoreObject] | [ScoreObject] | ||
Graphic | Graphic | ||
- | Position = (20, 20, 0) | + | Position = (-380, -280, 0) |
+ | Scale = 2 | ||
</ | </ | ||
- | Interesting to note the special Text definition. ScoreGraphic uses this instead of a texture from file. And the ScoreObject uses the graphic section as others before. | + | Interesting to note the special |
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 48: | Line 51: | ||
</ | </ | ||
- | Add 250 points whenever a monster is hit with a bullet: | + | 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 66: | Line 69: | ||
</ | </ | ||
- | And of course, 1000 points bonus if the star is reached: | + | 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 data/object | + | Save this into the '' |
Create a simple gameover graphic and object: | Create a simple gameover graphic and object: | ||
Line 95: | Line 98: | ||
[GameOverGraphic] | [GameOverGraphic] | ||
Texture = gameover.png | Texture = gameover.png | ||
+ | Pivot = center | ||
[GameOverObject] | [GameOverObject] | ||
Graphic | Graphic | ||
- | Position = (280, 250, -0.1) | + | Position = (0, 0, -0.1) |
</ | </ | ||
- | Create a timeline track with a single command to create the GameOverObject: | + | Create a timeline track with a single command to create the '' |
< | < | ||
Line 108: | Line 112: | ||
</ | </ | ||
- | Then finally | + | Then finally, change |
- | < | + | < |
if (orxString_Compare(recipientObjectName, | if (orxString_Compare(recipientObjectName, | ||
orxString_Compare(senderObjectName, | orxString_Compare(senderObjectName, | ||
Line 130: | 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 140: | Line 144: | ||
</ | </ | ||
- | And then set the variable on the orxObject_CreateFromConfig(" | + | And then set the '' |
- | < | + | < |
+ | scoreObject = orxObject_CreateFromConfig(" | ||
+ | orxObject_Enable(herosGun, | ||
scene = orxObject_CreateFromConfig(" | scene = orxObject_CreateFromConfig(" | ||
</ | </ | ||
Line 156: | 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> |