I try to create a class variable for later assign it a function, to later call this function just by using the variable. The idea is to be able to change the function pointed by the variable whe user touch differents buttons, and the call is made in an update loop function all functions i want assign in the variable is on the code because them contains a animation codes but different, and i don't want to use a switch, is more efficient to call a function as is made in Obj-C or C++ with pointer function
class declaration
private var animationFunction: (TimeInterval)
error on this line : Class 'MenuScene' has no initializers
try to assign function :
/**** interface ****/
func addInterface()
{
// couleur de fond et taille de la vue de la pub
self.backgroundColor = Constants.UI.colorsArray[appDelegate.theme][Constants.UI.C_0101100_COLOR_BACKGROUND]
// animation
animationFunction = standardAnimation
}
on line assignment i get this error : Cannot assign value of type '(TimeInterval) -> ()' (aka '(Double) -> ()') to type 'TimeInterval' (aka 'Double')
the function i want to assign into class variable
func standardAnimation(dtTime: TimeInterval)
{ do something }
Regards, Cedric