微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何在Phaser 3中调用相同类的方法

如何解决如何在Phaser 3中调用相同类的方法

我正在尝试从Phaser中从属于同一类的另一个方法调用一个方法。但是,this.functionName()引发错误(this.functionName不是函数),并且调用this.functionName不会返回任何内容。就像跳过那条线一样。另外,当我从Phaser的create()生命周期方法调用它时,它也可以正常工作。 这是我尝试调用方法代码

 onSelectAnswer(pointer,gameObject) {
    console.log(pointer,gameObject)
    //alert(gameObject.text)
    let answer = gameObject.text
    Questions.forEach((question) => {
        if(answer == question.rightAnswer) {
        this.success = true;
        this.successfulAnswers++;
        console.log('success',this.success)
        //alert(successfulAnswers)
        //this.playFeedback();
        }
    })

    this.activeQuestion = this.nextItem
    this.exerciseFirstQuestion = false
    try {
        console.log('prije')
        /* The line below seems to be the problem */
        this.getQuestion;
        console.log('poslije')
    } catch (error) {
        console.log('err',error)
    }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。