Game may be a digital game that ar rising in the contemporary world. Game Become Necessary as a way of amusement or as a way of relieving fatigue shortly. the passion of the developers still produce creative potential games so players do not get bored, and most well-liked to stay trustworthy to play Reviews their game created. every game features a definite score, as a result of the score to Determine or measure the power of a player.
creating score game |
How to Make Game Score?
Here I will give you a tutorial on how to make the score in the game. As in the picture below:game score |
layer |
The following script fragment typed in frame 1, layer player:
import flash.events.Event; stop(); var skorgame:Number=0; skor_txt.text=""+skorgame; stage.addEventListener(Event.ENTER_FRAME,stagemc); function stagemc(e:Event):void{ skorgame++; skor_txt.text=""+skorgame; } |
In the higher than script fragment score can increase ceaselessly (incremented by 1). This happens as a result of the employment skorgame ++, if victimization skorgame-- score can still decrease.
~ The test program by pressing Ctrl + Enter.
Explanation :
skorgame ++, together with skorgame = skorgame + 1;
How Adding Score Based on Time?
From the above title "How Adding Score Based on Time?", A score that I made this time about how a score value increases after a certain time. As an example :
Score will increase by 1 (one) after 10 seconds, 10 seconds later the score increased again to 2 (two), and so on.
A fragment of the script to score based on time:
import flash.events.Event; stop(); var skorgame:Number=0; var waktu:Number=0; skor_txt.text=""+skorgame; stage.addEventListener(Event.ENTER_FRAME,stagemc); function stagemc(e:Event):void{ waktu++; if(waktu==20){ skorgame++; skor_txt.text=""+skorgame; waktu=0; } } |
~ Testing program by pressing Ctrl + Enter.
Explanation:
var time: Number;, a variable used to determine the time.
then the event is written with time ++; -> Time will continue to increase by 1 (one), and then forwarded to if (condition), -> writing if (a == 20), if the time count reaches 20, the score will increase by 1 (one). After a period up to 20 (twenty) the time value will be returned to 0 (zero), and then re-calculate a score from 0 to 20, and so on.
then the event is written with time ++; -> Time will continue to increase by 1 (one), and then forwarded to if (condition), -> writing if (a == 20), if the time count reaches 20, the score will increase by 1 (one). After a period up to 20 (twenty) the time value will be returned to 0 (zero), and then re-calculate a score from 0 to 20, and so on.