onLoad: function () {
this._playerPlayAction(2,"downStop",true)
// 加速度方向开关
this.accUpper = false;
this.accDown = false;
this.accLeft = false;
this.accRight = false;
// 主角当前各方向速度
this.upperSpeed = 0;
this.downSpeed = 0;
this.leftSpeed = 0;
this.rightSpeed = 0;
//动作锁
this.upperLick = true;
this.downLick = true;
this.leftLick = true;
this.rightLick = true;
// 初始化键盘输入监听
this.setInputControl();
},
setInputControl: function () {
var self = this;
// 添加键盘事件监听
cc.eventManager.addListener({
event: cc.EventListener.KEYBOARD,
// 有按键按下时,判断是否是我们指定的方向控制键,并设置向对应方向速度
onKeyPressed: function(keyCode, event) {
switch(keyCode) {
case cc.KEY.w:
self.upperSpeed = self.accel;
self.downSpeed = 0;
self.leftSpeed = 0;