1
我試圖創建一個排行榜表我的街機遊戲spaceshooter,即時通訊做此表,因此不需要數據庫來存儲分數的變量,他們將是暫時的做一個排行榜表
var high1 : int;
var high2 : int;
var high3 : int;
var high4 : int;
var high5 : int;
function OnGUI() {
var camera;
camera = GameObject.FindWithTag("MainCamera");
var scorepoints;
scorepoints = camera.GetComponent(Scorescript).currentScore;
}
我正在使用Unity btw,並且即時嘗試訪問包含播放器當前得分的Scorescript,問題是它總是說它找不到腳本的組件,對象標籤名稱是正確的,並且腳本名稱也是,這裏是得分腳本:
var customSkin : GUISkin;
var enemy;
enemy = GameObject.FindWithTag("Enemy");
var currentScore : int = 0;
var visibleScore : int = 0;
function OnGUI() {
GUI.skin = customSkin;
GUILayout.BeginArea (Rect (Screen.width/1.2, Screen.height/10 ,300,200));
GUILayout.Box (visibleScore.ToString());
GUILayout.EndArea();
}
function AnimateVisibleScore() {
iTween.ValueTo (
gameObject,
{
"from" : visibleScore,
"to" : currentScore,
"onupdate" : "ChangeVisibleScore",
"time" : 0.5
}
);
}
function ChangeVisibleScore (i : int) {
visibleScore = i;
}
function IncrementScore (i : int) {
currentScore += i;
AnimateVisibleScore();
}
function DecrementScore (i : int) {
currentScore -= i;
AnimateVisibleScore();
}
而且,如果有人能夠完成這個特定的部分,我會非常感激。
正如一個尖端,而不是單獨的得分變量score1,score2等,使用數組。 – 2011-05-03 09:52:26
哈哈sry格式化D:,並感謝數組提示:D – MetalSlug 2011-05-03 10:07:23