// Update is called once per frame.
void Update () {
if(Input.GetKeyDown(KeyCode.RightArrow)){
// RIGHT MOVEMENT WILL GO HERE
}else if(Input.GetKeyDown(KeyCode.LeftArrow)){
// LEFT MOVEMENT WILL GO HERE
}
}
public void Init (Camera cam, int numItems, string[] arr) {
isoCamMain = cam;
numItemsToSpawn = numItems;
arrObjects = arr;
}
public void SpawnObject() {
int rand = Random.Range(1, numItemsToSpawn) - 1; // Offset for zero-based array.
// Pull in the object's name (corresponds to the file name in the Resource folder)
string s = arrObjects[rand];
GameObject temp = (GameObject) Resources.Load(s);
currSpawnObj = NGUITools.AddChild(isoCamMain.gameObject, temp) as GameObject;
currSpawnObj.GetComponent<UISprite>().MakePixelPerfect();
Vector3 newPos
= new Vector3
(0f, 200f, 0
.01f
); currPosition = newPos;
UITweener tp = TweenPosition.Begin(currSpawnObj, 0.1f, newPos);
tp.callWhenFinished = "OnSpawned";
tp.eventReceiver = this.gameObject;
TweenAlpha.Begin(currSpawnObj,0.0f,0.0f);
}
void OnSpawned(){
TweenAlpha.Begin(currSpawnObj,0.0f,1.0f);
Vector3 newPos
= new Vector3
(0f,
-200f, 0f
); UITweener tp = TweenPosition.Begin(currSpawnObj, tweenTimer, newPos);
tp.callWhenFinished = "OnComplete";
tp.eventReceiver = this.gameObject;
}
void OnComplete(){
Debug.Log("Animation Complete");
}