ccc 设置图片位置

cc.Class({
    extends: cc.Component,

    properties: {
        player:{
            default:null,
            type:cc.Sprite
        }
    },

    // use this for initialization
    onLoad: function () {
        var self=this
        
        cc.eventManager.addListener({
            event: cc.EventListener.TOUCH_ONE_BY_ONE,

            //开始
            onTouchBegan: function(touch, event) {
                
                
                var pos=touch.getLocation()
                pos.x-=480
                pos.y-=320
                self.player.node.position=pos
                return true; // don't capture event
            },

            //移动
            onTouchMoved: function(touch, event) {
                var pos=touch.getLocation()
                pos.x-=480
                pos.y-=320
                self.player.node.position=pos
            },
            
            //结束
            onTouchEnded: function(touch, event) {
                console.log("end")
            }
        }, self.node);
    },

    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {

    // },
});

原文地址:https://www.cnblogs.com/yufenghou/p/5431597.html