Rotation of Node on drag

Hi, I am looking for smooth rotation of a node on dragging it. Please help. Thanks in advance.

1 Like

Hope this helps. In the engine you just drag an drop the node that you want to rotate and put it in the “toRotate” box. It rotates the node but not any childs of the node. I am investigating this atm.

@property(cc.Vec2)
InitialPosition = new cc.Vec2(0,0);

@property(cc.Node)
toRotate = null;

@property
smoothness: number = 1;

start() {

    this.node.on("touchmove", function(event)
    {
        let touchInfo = event.touch.getDelta();

        this.InitialPosition = new cc.Vec2(touchInfo.x, touchInfo.y);

        if (this.toRotate != null)
        {
           this.toRotate.angle += (this.InitialPosition.x/this.smoothness);
        }
        else
        {
            cc.log("Can't access toRotate???");
        }

    }, this)

    this.node.on("touchend", function()
    {
        this.InitialPosition = new cc.Vec2(0,0);
    }, this)
}

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.