Hi! Tell me please how to change this code?
I want the man to jump from the keyboard. I tried to change the code myself, but nothing happened.
Here is this code:
cc.eventManager.addListener({
event: cc.EventListener.TOUCH_ONE_BY_ONE,
swallowTouches: true,
onTouchBegan: this.onTouchBegan,
onTouchMoved: this.onTouchMoved,
onTouchEnded: this.onTouchEnded
}, this)
onTouchBegan:function(touch, event) {
var pos = touch.getLocation();
event.getCurrentTarget().recognizer.beginPoint(pos.x, pos.y);
return true;
},
onTouchMoved:function(touch, event) {
var pos = touch.getLocation();
event.getCurrentTarget().recognizer.movePoint(pos.x, pos.y);
},
onTouchEnded:function(touch, event) {
var rtn = event.getCurrentTarget().recognizer.endPoint();
cc.log("rnt = " + rtn);
switch (rtn) {
case "up":
event.getCurrentTarget().jump();
break;
default:
break;
}
},