A SCORE Gui

Started by metalmario991, Sat 07/02/2015 00:52:08

Previous topic - Next topic

metalmario991

Excuse me but I want to have points in my game and I would like to know if and how I can but a display for it in the the options box and bar at the top of the screen.
(Also what is the name of the script function for adding the score?)

Slasher

#1
Hi

ags has a built-in score system (though you can make your own).

Basic:

make a Lable on your gui, name it something like LPoints.

In Global asc add this in the repeatedly_execute_always:

Code: ags

 function repeatedly_execute_always() {
 LPoints.Text=String.Format("%d",game.score) 
}


To add a score simpy add: 
Code: ags

GiveScore(15); //at the appropriate places in the scripts. In this case 15 points is added to the score.




Vincent

As slasher said before, you can make it easily by your own.
You should check this sections on the manual if you want to use the default one by AGS

game.score
The player's score. To modify the score, use the GiveScore script function.

game.score_sound
Sound effect to play when the player gets points, originally set in the editor.

game.total_score
Maximum possible score, initially set in the editor. 

GiveScore
Adds SCORE to the player's score. This is preferable to directly modifying the variable since it will play the score sound,
update any status lines and call the GOT_SCORE on_event function.


function on_event (EventType event, int data)

      eEventGotScore 
      called whenever the player's score changes
      DATA = number of points they got



String formatting
You will find many times in your game when you need to create a string based on the values of variables,
and functions like Display and String.Format allow you to do so.


SMF spam blocked by CleanTalk