Bu yüzden, her nesnenin duvar bölümleri gibi öğeleri gruplamak için kullanabileceğim bir etiket kümesinin bulunduğu, etiketler fikrine dayalı temel bir oyun motoru oluşturmaya çalışıyorum. ve hepsini bir kerede gerçekleştirin. Her bir nesneyi her nesne üzerinde aramak için bir döngü ile çevrelemek istemediğim için, her nesnede geçirilen yöntemi çağırabilecek bir yöntem yapmaya çalışıyorum. Burada Nesnelerin bir listesi üzerine parametre olarak bir işlev geçirme
bazı örnek Suto-koddur: Zaten sorunun bu tip diğer yanıtlar bir demet aracılığıyla baktım//have a list of objs. some door, some not.
//an example of stuff I could want to do
// - check returns on any functions called
// - call a function on a bunch of objects, possibly with parameters
if (runOnTag("door", isClosed())[aPositionInReturnList] == true){
runOnTag("door", open());
}
//the method
public couldBeAnyType[] runOnTag(String tag, function(anyPerams)){ //dont want the function to compile here
for (String currentObj : listOfObjsWith[tag]){
returns[index++] = currentObj.function(anyPerams); //so that it can be executed on this object
}
return returns; //want to be able to colect returns
}
ama onlarda ne olup bittiğini anlamıyorum. Eğer bunu daha kolay anlatabilirseniz, bunu çok takdir ediyorum.
nesneler listenizin tanımını gösterebilir misin? Bunu yapmanın daha iyi bir yolu olmalı – jack3694078