使用getComponent得到相同node下的sprite

不能这样使用getComponent得到sprite么?


另外发帖的时候为什么总是提示title无效,请描述的尽量详尽些?要多详尽?

或者要引用相同node下的sprite进行操作的话应该怎么搞?

请用 this.getComponent(cc.Sprite) 或者 this.getComponent(“cc.Sprite”)

谢谢,另外我刚刚试了一下,cc.Sprite.setFlippedY()被弃用了?现在creator用的是什么版本的cocos ?哪儿能找到靠谱的API?

用的是定制的新版 cocos,API 在 http://www.cocos.com/docs/creator/api/ 教程在 http://www.cocos.com/docs/creator/

多谢, 根据Node的API文档(rotation)为什么像下面这样设置旋转sprite没有旋转起来?

cc.Class({
    extends: cc.Component,

    properties: {
    },

    // use this for initialization
    onLoad: function () {
    },

    // called every frame, uncomment this function to activate update callback
    update: function (dt) {
        this.rotation += 45;
        this.rotation %= 360;
        console.log(this.rotation);
    },
});

console.log 一直打印 NaN?

脚本是组件,要旋转的是节点:

this.node.rotation += 45;
this.node.rotation %= 360;
console.log(this.node.rotation);

恩,多谢