properties: {
bg: cc.Node,
anim: cc.Animation,
player : cc.Node,
},
// use this for initialization
onLoad: function () {
var num = 200
var that = this
this.bg.on(cc.Node.EventType.TOUCH_START,function(event){
var pos = that.player.parent.convertToNodeSpaceAR(event.getLocation())
var playerPos =that.player.getPosition()
cc.log( pos,that.player.getPosition())
if (playerPos.x<pos.x){
that.player.getChildByName("anim").scaleX = -1
}
else {
that.player.getChildByName("anim").scaleX = 1
}
var time = cc.pDistance(pos,playerPos)/num
var moveto = cc.moveTo(time,pos)
that.player.stopAllActions()
that.player.runAction(moveto)
that.anim.play('plyerRun')
clearTimeout(that.timeOut)
that.timeOut = setTimeout(function () {
that.anim.play('plyerAnima')
},time*1000)
})
// for (var i = 0;i<=113)
},