i made my animation clip like below
indent preformatted text by 4 spacescc.Class({
extends: cc.Component,
properties: {
player: {
default: null,
type: cc.Node
},
playerAction: {
default: null,
type: cc.Animation
}
// foo: {
// default: null,
// url: cc.Texture2D, // optional, default is typeof default
// serializable: true, // optional, default is true
// visible: true, // optional, default is true
// displayName: 'Foo', // optional
// readonly: false, // optional, default is false
// },
// ...
},
// use this for initialization
onLoad: function () {
var self = this;
cc.eventManager.addListener({
event: cc.EventListener.KEYBOARD,
onKeyPressed: function(keyCode, event) {
self.playerAction.getAnimationState();
switch(keyCode) {
case cc.KEY.up:
console.log('up key pressed');
self.changeAction('jump');
break;
case cc.KEY.right:
console.log('right key pressed');
self.changeAction('sidejump');
break;
}
}
}, self.node);
},
changeAction: function(action) {
this.playerAction.play(action);
},
onAniStart: function(name) {
console.log(name);
},
onAnimationEnd: function(name) {
console.log(name);
this.changeAction('stand');
}
});
but i cannot get any message from console.
do i sth wrong?
