I have code:
iTween.MoveTo(
gameObject,
iTween.Hash("x",_x,"z",_y, "time", 2.0f, "easetype",
iTween.EaseType.easeInExpo,
"oncomplete", "afterPlayerMove",
"oncompleteparams", iTween.Hash("value", _fieldIndex)
));
but I don't know how to use oncompleteparams. There is no example in the official manual.
How do you use oncompleteparams?
Here is the direct doc for the
Itween.MoveTofunction.oncompleteparams expects
Objectas argument. This means that almost any datatype can be passed in to it. For example,string,bool,int,float,double, andobject instanceare one of datatypes that can be passed to it.On the callback side, you make the callback function take Object as parameter. Inside the callback function, you cast the
Objectparameter to the type of datatype you passed to it.Example:
Callback:
As you can see, we are passing 5 to the
oncompleteparamsfunction and 5 is an integer. In theafterPlayerMovecallback function, we cast it back to integer to get the result.In your example, you used
iTween.Hashfor theoncompleteparamsso you must cast toHashtablesince iTween.Hash returnsHashtable. After that, to get the values in the Hashtable, you have to cast to that type too.Callback:
Assuming that
_fieldIndexis anint.Finally, your code is unreadable. Simplify this code to make it easier for others to help you next time.
Complete simplified Example: