嘿伙计们,我正在为一个班级项目编写一些代码,出于某种原因,我在课堂上得到的演示代码的工作方式不同。这些错误没有造成任何错误,因为我可以得到一些帮助调试我知道它可能迟缓了。提前非常感谢。
function BuildGrid()
{
//begin with a BeginVertical() call so that controls
//are stacked vertically
GUILayout.BeginVertical();
GUILayout.FlexibleSpace();
//begin loopping for the rows
for(var i=0; i<rows; i++)
{
//call BeginHorizontal() so that controls are stacked
//horizontally
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
//begin looping for the columns
for(var j=0; j<cols; j++)
{
//getting the card object that resides
//at this location in the array
var card:Object = aGrid[i][j];
//the definition for the backside (visible part for the card
var img : String;
//check if the card is face up, if so, show the robot part
//if not show the wrench
if(card.ifFaceUp)
{
img = card.img;
}
else
{
img = "wrench";
}
//create a button using a picture instead of
//text. Getting the picture from the Resources
if(GUILayout.Button(Resources.Load(img),
GUILayout.Width(cardW)))
{
flipCardFaceUp(card);
//print to the debug the name of the picture
Debug.Log(card.img);
}
}
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}
GUILayout.FlexibleSpace();
GUILayout.EndVertical();
}//end buildGrid
定义 ifFaceUP 和 img 的类
class Card extends System.Object
{
//is the card face up
var ifFaceUp:boolean = false;
//has the card been matched
var ifMatched:boolean = false;
//image for the card
var img: String;
//constructor
function Card(img : String)
{
this.img = img;
}
}
错误: http: //puu.sh/2clHw