I'm using Cocos Creator and TypeScript to develop my web based 2D game. I faced the following error while calling onTapFalse function.
Uncaught TypeError: playableObj.onTapFalse is not a function
here's onTapFalse function:
@ccclass('PlayableObject')
export class PlayableObject extends Component {
public onTapFalse() {
// ...
}
}
I call onTapFalse here:
@ccclass('CorrectionHandler')
export class CorrectionHandler extends Singleton<CorrectionHandler> {
public correct(playableObj: PlayableObject){
if (!playableObj.isTrue)playableObj.onTapFalse();
}
}
What's the solution?
thanks
I found out I passed a parameter of wrong type (a type other than
PlayableObject) to thecorrectfunction. SoplayableObject.isTruewas alwaysfalsebecause of there isn't theisTruein this class, also there isn't theonTapFalsefunction.