cocos creator

ar po1 = this.hand.getPosition()
       
        if(0){
            //局部坐标转换
            var po2 = this.canvas.convertToNodeSpaceAR(touch.getLocation())
            cc.log(po1.x,po1.y,'  | ',po2.x, po2.y)
        }else{
            //全局坐标转换
            po1 = this.bg.convertToWorldSpaceAR(po1)
            po1 = cc.pSub(touch.getLocation(), po1)
        }
        var at = cc.radiansToDegrees(cc.pAngleSigned(po1, cc.p(0,1)))
        this.hand.rotation = at

自定义事件

var event = new cc.Event.EventCustom(GameEvent.bugRun, true)
        event.setUserData(this.node)
        var ob = cc.find('script')
        cc.find('script').dispatchEvent(event)

你可能感兴趣的:(cocos creator)