This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
guides:beginners:text_and_game_over [2015/10/24 03:09 (9 years ago)] – created sausage | en:guides:beginners:text_and_game_over [2023/03/28 21:13 (13 months ago)] (current) – iarwain | ||
---|---|---|---|
Line 15: | Line 15: | ||
[ScoreObject] | [ScoreObject] | ||
Graphic | Graphic | ||
- | Position = (20, 20, 0) | + | Position = (-380, -280, 0) |
</ | </ | ||
- | 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: | ||
Line 29: | Line 29: | ||
</ | </ | ||
- | Then a little function to increase the score and update the ScoreObject: | + | Next, create a score object and assign it to the scoreObject variable in the Init() function: |
+ | |||
+ | < | ||
+ | scoreObject = orxObject_CreateFromConfig(" | ||
+ | </ | ||
+ | |||
+ | Add a little function to increase the score and update the ScoreObject: | ||
< | < | ||
Line 36: | Line 42: | ||
orxCHAR formattedScore[6]; | orxCHAR formattedScore[6]; | ||
- | | + | |
orxObject_SetTextString(scoreObject, | orxObject_SetTextString(scoreObject, | ||
Line 42: | Line 48: | ||
</ | </ | ||
- | Then 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: |
< | < | ||
Line 60: | Line 66: | ||
</ | </ | ||
- | 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: |
< | < | ||
Line 73: | Line 79: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | Compile and run it. Shoot some monsters and collect the star and observe the score increasing. | ||
That takes care of having an active score object. | That takes care of having an active score object. | ||
Line 78: | Line 86: | ||
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: | ||
- | {{ :en:orx: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 87: | Line 95: | ||
[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 100: | Line 109: | ||
</ | </ | ||
- | Then finally | + | Then finally, change |
< | < | ||
Line 106: | Line 115: | ||
orxString_Compare(senderObjectName, | orxString_Compare(senderObjectName, | ||
){ | ){ | ||
- | CreateExplosionAtObject(pstSenderObject, " | + | CreateExplosionAtObject(pstRecipientObject, " |
orxObject_SetLifeTime(pstSenderObject, | orxObject_SetLifeTime(pstSenderObject, | ||
orxObject_Enable(pstRecipientObject, | orxObject_Enable(pstRecipientObject, | ||
Line 115: | Line 124: | ||
orxString_Compare(recipientObjectName, | orxString_Compare(recipientObjectName, | ||
){ | ){ | ||
- | CreateExplosionAtObject(pstRecipientObject, " | + | CreateExplosionAtObject(pstSenderObject, " |
- | orxObject_SetLifeTime(pstSenderObject, 0); | + | orxObject_SetLifeTime(pstRecipientObject, 0); |
orxObject_Enable(pstSenderObject, | orxObject_Enable(pstSenderObject, | ||
orxObject_AddTimeLineTrack(scene, | orxObject_AddTimeLineTrack(scene, | ||
Line 122: | Line 131: | ||
</ | </ | ||
- | Becuase | + | Because |
< | < | ||
Line 132: | Line 141: | ||
</ | </ | ||
- | And then set the variable on the orxObject_CreateFromConfig(" | + | And then set the '' |
< | < | ||
Line 144: | Line 153: | ||
Well friends, that's game over. If you reached the end here, great job! You've learned many of the major features of Orx. | Well friends, that's game over. If you reached the end here, great job! You've learned many of the major features of Orx. | ||
- | If you need more help, go to the tutorials | + | If you need more help, go to the [[en:tutorials: |
+ | |||
+ | If you need quick examples, you can visit the [[en: | ||
- | If you need quick examples, you can visit the examples section | + | If you get stuck, please post it to the [[http:// |
- | If you get stuck, please post it to the forum, and for general chat, come and join us over in gitter. Hope to see you there. | + | {{section> |