【问题标题】:how to rotate a node in cocosjs?如何在 cocosjs 中旋转节点?
【发布时间】:2018-03-25 16:00:46
【问题描述】:

我是 Cocos Creator 的新手。

尝试使用操作旋转节点。

openGates(){
    const gateLeft = this.node.getChildByName("gateLeft")
    const gateRight = this.node.getChildByName("gateLeft")

    const rotateLeft = cc.RotateBy.create(2, 40);
    const rotateRight = cc.RotateBy.create(2, -40);

    gateLeft.runAction(rotateLeft)
    gateRight.runAction(rotateRight)
},

我收到了这个错误

Uncaught TypeError: cc.RotateBy.create is not a function

有什么想法吗?

【问题讨论】:

  • cc 是在哪里定义的?您可以尝试打印cc 并检查可用的功能
  • 您也将gateLeftgateRight 设置为同一个节点,想知道如何处理并发操作(根据Felipe 的评论将引用解析为cc 之后)。

标签: cocos2d-iphone cocos2d-js


【解决方案1】:

请使用const rotateLeft = new cc.RotateBy(2, 40); 而不是使用 create 方法。 还有“;”您的前两个陈述中缺少

【讨论】:

    猜你喜欢
    • 2015-07-10
    • 2017-05-08
    • 2011-05-29
    • 2013-10-23
    • 1970-01-01
    • 2018-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多